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 <[EMAIL PROTECTED]>:

> 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:[EMAIL PROTECTED]
> Sent: Monday, January 26, 2004 11:10 AM
> To: [EMAIL PROTECTED]
> 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 <mailto:[EMAIL PROTECTED]>
D.O.Tech       <http://www.dotech.com/>

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

Reply via email to