You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Vinicius Carvalho <ca...@superig.com.br> on 2004/01/26 19:10:29 UTC
Looping through a VO collection
Hi there! I have a collection of VOs in my request, I'd like to loop
through it using the <html:logic> and <html:link>
The idea is to create links for a page. But how do I access the properties
of the VO? Let's suppose I want to build a list of links like this
How do I combine those tags to render such string:
someAction.do?name=VO.getName()&id=VO.getID();
??
Thanks
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
RE: Looping through a VO collection
Posted by Richard Hightower <rh...@arc-mind.com>.
Cool beans! I forgot about that one. Good show...
Rick Hightower
Developer
Struts/J2EE training -- http://www.arc-mind.com/strutsCourse.htm
Struts/J2EE consulting --
http://www.arc-mind.com/consulting.htm#StrutsMentoring
-----Original Message-----
From: Kris Schneider [mailto:kris@dotech.com]
Sent: Monday, January 26, 2004 11:36 AM
To: Struts Users Mailing List
Subject: RE: Looping through a VO collection
JSTL
<jsp:useBean id="params" class="java.util.HashMap"/>
<c:forEach var="vo" items="${voList}">
<c:set target="${params}" property="name" value="${vo.name}"/>
<c:set target="${params}" property="ID" value="${vo.ID}"/>
<html:link action="/someAction" name="params">
<c:out value="${vo.ID}"/>
</html:link>
</c:forEach>
Quoting Richard Hightower <rh...@arc-mind.com>:
> Classic Struts
> <logic:iterate id="foo" name="bar" property="foos">
>
> <html:link action="someAction" paramID="id" paramName="foo"
> paramProperty="id"><bean:write name="foo" property="name"/></html:link>
> </logic:iterate>
>
> JSTL
> <c:forEach var="foo" collection="${bar.foos}">
> <html:link action="someAction" paramID="id" paramName="foo"
> paramProperty="id"><c:out value="${foo.id}"/></html:link>
> </c:forEach>
>
>
> JSP 2.0
> <c:forEach var="foo" collection="${bar.foos}">
> <html:link action="someAction" paramID="id" paramName="foo"
> paramProperty="id">${foo.id}</html:link>
> </c:forEach>
>
>
> If you want to pass multiple parameters you could do this....
>
> <logic:iterate id="foo" name="bar" property="foos"
> type="org.mycompany.Foo">
> <jsp:useBean id="params" class="java.util.HashMap"/>
> <%
> params.put("name",foo.getName());
> params.put("id",foo.getId());
> %>
> <html:link action="someAction" paramID="id" name="params"><bean:write
> name="foo" property="name"/></html:link>
> </logic:iterate>
>
> At this point however, you may be better off using c:url instead of
> html:link (to avoid Java scriptlets).
>
> Rick Hightower
> Developer
>
> Struts/J2EE training -- http://www.arc-mind.com/strutsCourse.htm
>
> Struts/J2EE consulting --
> http://www.arc-mind.com/consulting.htm#StrutsMentoring
>
>
> -----Original Message-----
> From: Vinicius Carvalho [mailto:carvalho.vinicius@superig.com.br]
> Sent: Monday, January 26, 2004 11:10 AM
> To: struts-user@jakarta.apache.org
> Subject: Looping through a VO collection
>
>
> Hi there! I have a collection of VOs in my request, I'd like to loop
> through it using the <html:logic> and <html:link>
> The idea is to create links for a page. But how do I access the properties
> of the VO? Let's suppose I want to build a list of links like this
> How do I combine those tags to render such string:
>
> someAction.do?name=VO.getName()&id=VO.getID();
>
> ??
>
> Thanks
--
Kris Schneider <ma...@dotech.com>
D.O.Tech <http://www.dotech.com/>
---------------------------------------------------------------------
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
RE: Looping through a VO collection
Posted by Kris Schneider <kr...@dotech.com>.
JSTL
<jsp:useBean id="params" class="java.util.HashMap"/>
<c:forEach var="vo" items="${voList}">
<c:set target="${params}" property="name" value="${vo.name}"/>
<c:set target="${params}" property="ID" value="${vo.ID}"/>
<html:link action="/someAction" name="params">
<c:out value="${vo.ID}"/>
</html:link>
</c:forEach>
Quoting Richard Hightower <rh...@arc-mind.com>:
> Classic Struts
> <logic:iterate id="foo" name="bar" property="foos">
>
> <html:link action="someAction" paramID="id" paramName="foo"
> paramProperty="id"><bean:write name="foo" property="name"/></html:link>
> </logic:iterate>
>
> JSTL
> <c:forEach var="foo" collection="${bar.foos}">
> <html:link action="someAction" paramID="id" paramName="foo"
> paramProperty="id"><c:out value="${foo.id}"/></html:link>
> </c:forEach>
>
>
> JSP 2.0
> <c:forEach var="foo" collection="${bar.foos}">
> <html:link action="someAction" paramID="id" paramName="foo"
> paramProperty="id">${foo.id}</html:link>
> </c:forEach>
>
>
> If you want to pass multiple parameters you could do this....
>
> <logic:iterate id="foo" name="bar" property="foos"
> type="org.mycompany.Foo">
> <jsp:useBean id="params" class="java.util.HashMap"/>
> <%
> params.put("name",foo.getName());
> params.put("id",foo.getId());
> %>
> <html:link action="someAction" paramID="id" name="params"><bean:write
> name="foo" property="name"/></html:link>
> </logic:iterate>
>
> At this point however, you may be better off using c:url instead of
> html:link (to avoid Java scriptlets).
>
> Rick Hightower
> Developer
>
> Struts/J2EE training -- http://www.arc-mind.com/strutsCourse.htm
>
> Struts/J2EE consulting --
> http://www.arc-mind.com/consulting.htm#StrutsMentoring
>
>
> -----Original Message-----
> From: Vinicius Carvalho [mailto:carvalho.vinicius@superig.com.br]
> Sent: Monday, January 26, 2004 11:10 AM
> To: struts-user@jakarta.apache.org
> Subject: Looping through a VO collection
>
>
> Hi there! I have a collection of VOs in my request, I'd like to loop
> through it using the <html:logic> and <html:link>
> The idea is to create links for a page. But how do I access the properties
> of the VO? Let's suppose I want to build a list of links like this
> How do I combine those tags to render such string:
>
> someAction.do?name=VO.getName()&id=VO.getID();
>
> ??
>
> Thanks
--
Kris Schneider <ma...@dotech.com>
D.O.Tech <http://www.dotech.com/>
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
RE: Looping through a VO collection
Posted by Richard Hightower <rh...@arc-mind.com>.
Classic Struts
<logic:iterate id="foo" name="bar" property="foos">
<html:link action="someAction" paramID="id" paramName="foo"
paramProperty="id"><bean:write name="foo" property="name"/></html:link>
</logic:iterate>
JSTL
<c:forEach var="foo" collection="${bar.foos}">
<html:link action="someAction" paramID="id" paramName="foo"
paramProperty="id"><c:out value="${foo.id}"/></html:link>
</c:forEach>
JSP 2.0
<c:forEach var="foo" collection="${bar.foos}">
<html:link action="someAction" paramID="id" paramName="foo"
paramProperty="id">${foo.id}</html:link>
</c:forEach>
If you want to pass multiple parameters you could do this....
<logic:iterate id="foo" name="bar" property="foos"
type="org.mycompany.Foo">
<jsp:useBean id="params" class="java.util.HashMap"/>
<%
params.put("name",foo.getName());
params.put("id",foo.getId());
%>
<html:link action="someAction" paramID="id" name="params"><bean:write
name="foo" property="name"/></html:link>
</logic:iterate>
At this point however, you may be better off using c:url instead of
html:link (to avoid Java scriptlets).
Rick Hightower
Developer
Struts/J2EE training -- http://www.arc-mind.com/strutsCourse.htm
Struts/J2EE consulting --
http://www.arc-mind.com/consulting.htm#StrutsMentoring
-----Original Message-----
From: Vinicius Carvalho [mailto:carvalho.vinicius@superig.com.br]
Sent: Monday, January 26, 2004 11:10 AM
To: struts-user@jakarta.apache.org
Subject: Looping through a VO collection
Hi there! I have a collection of VOs in my request, I'd like to loop
through it using the <html:logic> and <html:link>
The idea is to create links for a page. But how do I access the properties
of the VO? Let's suppose I want to build a list of links like this
How do I combine those tags to render such string:
someAction.do?name=VO.getName()&id=VO.getID();
??
Thanks
---------------------------------------------------------------------
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
RE: Looping through a VO collection
Posted by Matthias Wessendorf <ma...@matthias-wessendorf.de>.
hi Vinicius
<logic:iterate id="element" name="allVOS">
<html:link action="/doSomething" paramId="name" paramName="element"
paramProperty="propertyOfA_VO">
link me
</html:link>
</logic:iterate>
this shoud work
cheers,
matthias
-----Original Message-----
From: Vinicius Carvalho [mailto:carvalho.vinicius@superig.com.br]
Sent: Monday, January 26, 2004 7:10 PM
To: struts-user@jakarta.apache.org
Subject: Looping through a VO collection
Hi there! I have a collection of VOs in my request, I'd like to
loop
through it using the <html:logic> and <html:link>
The idea is to create links for a page. But how do I access the
properties
of the VO? Let's suppose I want to build a list of links like this How
do I combine those tags to render such string:
someAction.do?name=VO.getName()&id=VO.getID();
??
Thanks
---------------------------------------------------------------------
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