You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Brandon Mercer <br...@eutonian.com> on 2005/05/20 15:15:53 UTC

Nested Beans

Hello Everyone,
I've got an easy one, that is stupifying me because of my tiredness. 
I've got a POJO with a List in it.  The List is a list of beans.  In my
JSP page I'm trying to iterate over the list of beans.  Here goes:

public class Information {
    private String name = null;
    private String addr = null;
    private List School = null;
<snip/>

School is a bean that looks like:

public class School {
    private String schoolname = null;
    private String location = null;
}

Then I set that information in the session:
session.setAttribute("information", information);

Each information bean will have a list of schools in it and I'd like to
iterate over that list on the JSP page but I'm not sure how far I am
from the truth!  :-P  Right now I've got:

<bean:write name="information" property="name"/>
<bean:write name="information" property="addr"/>

<logic:iterate ?????????????? 

Thanks for your help everyone.
Brandon


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


Re: Nested Beans

Posted by Brandon Mercer <br...@eutonian.com>.
Hubert Rabago wrote:

>You might find the nested tags interesting:
>
><%@ taglib uri="/WEB-INF/struts-nested.tld" prefix="nested" %>
>
><nested:root name="information">
>    <nested:write property="name"/><br/>
>    <nested:write property="addr"/><br/>
>
>    <nested:iterate property="school">
>         <nested:write property="schoolname"/><br/>
>         <nested:write property="location"/><br/>
>    </nested:iterate>
></nested:root>
>
>Hubert
>  
>
Looks like what I want to do.  I'll go check it out, thanks for the link.
Brandon


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


Re: Nested Beans

Posted by Hubert Rabago <hr...@gmail.com>.
Works for me.  If you want, I can send you code later in the day. 
(Will be busy for most of the afternoon).  Or, you can post more of
your code and maybe someone else will spot something.

Hubert

On 5/20/05, Brandon Mercer <br...@eutonian.com> wrote:
> Hubert Rabago wrote:
> 
> >You might find the nested tags interesting:
> >
> ><%@ taglib uri="/WEB-INF/struts-nested.tld" prefix="nested" %>
> >
> ><nested:root name="information">
> >    <nested:write property="name"/><br/>
> >    <nested:write property="addr"/><br/>
> >
> >    <nested:iterate property="school">
> >         <nested:write property="schoolname"/><br/>
> >         <nested:write property="location"/><br/>
> >    </nested:iterate>
> ></nested:root>
> >
> >
> Still a bit miffed.  I'm not sure if it's beanutils that is not copying
> the List into the new bean... or if I can't figure out this nested tag.
> I put that code snippet into my JSP and changed the information around
> several times and I still don't see the info being printed on my page.
> I guess my next question is... is the JSP code different if I have a
> list of beans, as opposed to a single Bean stored in my bean.  I have
> the List.  Another OT question is, will beanutils copy a List of Beans
> into the new Bean as a List of beans?  i.e.
> List school = mgr.getSchoolList(id);
> 
> BeanUtils.copyProperties(information,  schools);
> 
> Thanks Guys!
> Brandon
>

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


Re: Nested Beans

Posted by Brandon Mercer <br...@eutonian.com>.
Hubert Rabago wrote:

>You might find the nested tags interesting:
>
><%@ taglib uri="/WEB-INF/struts-nested.tld" prefix="nested" %>
>
><nested:root name="information">
>    <nested:write property="name"/><br/>
>    <nested:write property="addr"/><br/>
>
>    <nested:iterate property="school">
>         <nested:write property="schoolname"/><br/>
>         <nested:write property="location"/><br/>
>    </nested:iterate>
></nested:root>
>  
>
Still a bit miffed.  I'm not sure if it's beanutils that is not copying
the List into the new bean... or if I can't figure out this nested tag. 
I put that code snippet into my JSP and changed the information around
several times and I still don't see the info being printed on my page. 
I guess my next question is... is the JSP code different if I have a
list of beans, as opposed to a single Bean stored in my bean.  I have
the List.  Another OT question is, will beanutils copy a List of Beans
into the new Bean as a List of beans?  i.e.
List school = mgr.getSchoolList(id);

BeanUtils.copyProperties(information,  schools);

Thanks Guys!
Brandon

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


Re: Nested Beans

Posted by Hubert Rabago <hr...@gmail.com>.
You might find the nested tags interesting:

<%@ taglib uri="/WEB-INF/struts-nested.tld" prefix="nested" %>

<nested:root name="information">
    <nested:write property="name"/><br/>
    <nested:write property="addr"/><br/>

    <nested:iterate property="school">
         <nested:write property="schoolname"/><br/>
         <nested:write property="location"/><br/>
    </nested:iterate>
</nested:root>

Hubert

On 5/20/05, Brandon Mercer <br...@eutonian.com> wrote:
> Hello Everyone,
> I've got an easy one, that is stupifying me because of my tiredness.
> I've got a POJO with a List in it.  The List is a list of beans.  In my
> JSP page I'm trying to iterate over the list of beans.  Here goes:
> 
> public class Information {
>     private String name = null;
>     private String addr = null;
>     private List School = null;
> <snip/>
> 
> School is a bean that looks like:
> 
> public class School {
>     private String schoolname = null;
>     private String location = null;
> }
> 
> Then I set that information in the session:
> session.setAttribute("information", information);
> 
> Each information bean will have a list of schools in it and I'd like to
> iterate over that list on the JSP page but I'm not sure how far I am
> from the truth!  :-P  Right now I've got:
> 
> <bean:write name="information" property="name"/>
> <bean:write name="information" property="addr"/>
> 
> <logic:iterate ??????????????
> 
> Thanks for your help everyone.
> Brandon
>

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