Mike,

If I understand you correctly, you have a bean that contains an arraylist which also 
contains an arraylist?.... 

If this is the case, I just resolved this issue myself. I have bean A that contains a 
ArrayList getOtherArrayList() method.... the other arraylist contains attributes of 
another bean (bean B).... and to further compound the issues... bean B contains an 
arraylist that contains a ArrayList with is attributes of yet another bean.

I needed to display all of the contents and it resulted in a nested iterate tag. If 
this is want you are wanting to do let me know and I can send you the example I 
used....

David

-----Original Message-----
From: Mike R. Phelan [mailto:[EMAIL PROTECTED]
Sent: Saturday, January 17, 2004 2:11 PM
To: [EMAIL PROTECTED]
Cc: Edwin K. Brown; Bryan C. Harris
Subject: reference non-String/"complex" JavaBean attributes via
struts-bean tag library?


Hi all,

Is there a way to directly reference a complex Object attribute within a JavaBean on a 
JSP via the struts-bean tag library?

I have had good luck placing ArrayList objects in the HttpSession, then referencing 
them in a JSP:

Action subclass excerpt:
session.setAttribute("projects", projectsArrayList);

JSP excerpt:
<logic:present scope="session" name="projects">
...
  <logic:iterate id="project" name="projects">
...
    <bean:write name="project" property="name">
    <bean:write name="project" property="lastModificationDate">
...
  </logic:iterate>
...
</logic:present>

However, I would like to reference an ArrayList that exists within the 
projectsArrayList object. I was hoping that perhaps I could do something like this:

fantasy JSP excerpt:
<logic:present scope="session" name="projects">
...
  <logic:iterate id="project" name="projects">
...
    <bean:write name="project" property="name">
    <bean:write name="project" property="lastModificationDate">
...
  </logic:iterate>
...
<logic:iterate id="teamMember" name="projects.teamMembers"> <!--FANTASY PART-->
...
  <bean:write name="teamMember" property="firstName"> <!--FANTASY PART-->
  <bean:write name="teamMember" property="lastName"> <!--FANTASY PART-->
...
</logic:iterate> <!--NEW PART-->
</logic:present>

Or, even better, with nested iterators:
<logic:present scope="session" name="projects">
...
  <logic:iterate id="project" name="projects">
...
    <bean:write name="project" property="name">
    <bean:write name="project" property="lastModificationDate">
...
    <logic:iterate id="teamMember" name="projects.teamMembers"> <!--FANTASY PART-->
...
      <bean:write name="teamMember" property="firstName"> <!--FANTASY PART-->
      <bean:write name="teamMember" property="lastName"> <!--FANTASY PART-->
...
    </logic:iterate> <!--FANTASY PART-->
...
  </logic:iterate>
</logic:present>

I currently get around this by placing two different Objects into the HttpSession, 
then referencing them separately. This workaround is limiting me for newer 
functionality, as I need something that keeps the class heirarchy intact.

Is there a way to do this? When I try to use "dot referencing" (projects.TeamMembers), 
I get nothing rendered on the JSP page. Am I mangling the reference to a sub-object in 
the struts-bean tag library? Is the fantasy code above actually valid?

Thanks in advance for any help.

Mike Phelan


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to