You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Michael McGrady <mi...@michaelmcgrady.com> on 2004/01/18 17:46:55 UTC

RE: reference non-String/"complex" JavaBean attributes via struts-bean tag library?

I would be interested in this example.  Thanks.  Please send it to 
michael@michaelmcgrady.com instead of mike@michaelmcgrady.com.  Thanks again.

At 08:52 PM 1/17/2004, David Liles wrote:
>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:mrphelan@vsticorp.com]
>Sent: Saturday, January 17, 2004 2:11 PM
>To: struts-user@jakarta.apache.org
>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: struts-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: struts-user-help@jakarta.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org