You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Minghui Yu <mi...@gmail.com> on 2007/11/27 12:43:35 UTC
bean:write on a Collection
In my Action, I have: request.setAttribute("book", book);
book is a Book object, which has a getAuthors method. getAuthors
returns a collection (Set<String>)
in JSP page, I want to list authors one by one. How shall I do?
<bean:write name="book" property="authors" /> does not work as I want.
Thanks,
--
Thanks & Have a good day,
YU, Minghui
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: bean:write on a Collection
Posted by Dave Newton <ne...@yahoo.com>.
JSTL's <c:forEach ... /> or, if you must,
<logic:iterate ... />.
d.
--- Minghui Yu <mi...@gmail.com> wrote:
> struts 1.
>
> I barely made it work by using jsp and bean:define.
>
> <bean:define id="test" name="book"
> type="org.lonetree.tc.core.Book" />
> <%
> Iterator<String> itr=test.getAuthors().iterator();
> while (itr.hasNext())
> {
> out.println(itr.next());
> out.println("<br>");
> }
> %>
>
> I'd like to know how to do in in a nice way.
>
> Thanks.
>
> On Nov 27, 2007 3:57 AM, Omkar Patil
> <os...@gmail.com> wrote:
> >
> > Are you using struts1 or struts2?
> >
> > - Omkar
> >
> >
> > Minghui Yu wrote:
> > >
> > > In my Action, I have:
> request.setAttribute("book", book);
> > >
> > > book is a Book object, which has a getAuthors
> method. getAuthors
> > > returns a collection (Set<String>)
> > >
> > > in JSP page, I want to list authors one by one.
> How shall I do?
> > >
> > > <bean:write name="book" property="authors" />
> does not work as I want.
> > >
> > > Thanks,
> > >
> > > --
> > > Thanks & Have a good day,
> > >
> > > YU, Minghui
> > >
> > >
>
---------------------------------------------------------------------
> > > To unsubscribe, e-mail:
> user-unsubscribe@struts.apache.org
> > > For additional commands, e-mail:
> user-help@struts.apache.org
> > >
> > >
> > >
> >
> > --
> > View this message in context:
>
http://www.nabble.com/bean%3Awrite-on-a-Collection-tf4881224.html#a13969461
> > Sent from the Struts - User mailing list archive
> at Nabble.com.
> >
> >
> >
>
---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> user-unsubscribe@struts.apache.org
> > For additional commands, e-mail:
> user-help@struts.apache.org
> >
> >
>
>
>
> --
> Thanks & Have a good day,
>
> YU, Minghui
>
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> user-unsubscribe@struts.apache.org
> For additional commands, e-mail:
> user-help@struts.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: bean:write on a Collection
Posted by Minghui Yu <mi...@gmail.com>.
struts 1.
I barely made it work by using jsp and bean:define.
<bean:define id="test" name="book" type="org.lonetree.tc.core.Book" />
<%
Iterator<String> itr=test.getAuthors().iterator();
while (itr.hasNext())
{
out.println(itr.next());
out.println("<br>");
}
%>
I'd like to know how to do in in a nice way.
Thanks.
On Nov 27, 2007 3:57 AM, Omkar Patil <os...@gmail.com> wrote:
>
> Are you using struts1 or struts2?
>
> - Omkar
>
>
> Minghui Yu wrote:
> >
> > In my Action, I have: request.setAttribute("book", book);
> >
> > book is a Book object, which has a getAuthors method. getAuthors
> > returns a collection (Set<String>)
> >
> > in JSP page, I want to list authors one by one. How shall I do?
> >
> > <bean:write name="book" property="authors" /> does not work as I want.
> >
> > Thanks,
> >
> > --
> > Thanks & Have a good day,
> >
> > YU, Minghui
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
> >
> >
>
> --
> View this message in context: http://www.nabble.com/bean%3Awrite-on-a-Collection-tf4881224.html#a13969461
> Sent from the Struts - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
--
Thanks & Have a good day,
YU, Minghui
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: bean:write on a Collection
Posted by Omkar Patil <os...@gmail.com>.
Are you using struts1 or struts2?
- Omkar
Minghui Yu wrote:
>
> In my Action, I have: request.setAttribute("book", book);
>
> book is a Book object, which has a getAuthors method. getAuthors
> returns a collection (Set<String>)
>
> in JSP page, I want to list authors one by one. How shall I do?
>
> <bean:write name="book" property="authors" /> does not work as I want.
>
> Thanks,
>
> --
> Thanks & Have a good day,
>
> YU, Minghui
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
>
--
View this message in context: http://www.nabble.com/bean%3Awrite-on-a-Collection-tf4881224.html#a13969461
Sent from the Struts - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org