File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes logic:iterate & DTO Problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "logic:iterate & DTO Problem" Watch "logic:iterate & DTO Problem" New topic

logic:iterate & DTO Problem

Eibhlin Reid

Joined: Nov 04, 2004
Posts: 28
Does anyone know if it is possible to use <bean:write tag on a collection of DTO objects, within a <logic:iterate tag?
Horatio Westock
Ranch Hand

Joined: Feb 23, 2005
Posts: 221
Yes, you can use logic:iterator to iterate through the collection, then use bean:write to write out info from your DTOs:


Eibhlin Reid

Joined: Nov 04, 2004
Posts: 28
Thanks for that, we are already using the first piece of code EXACTLY as you gave it:

<logic resent name="topicsList">
<logic:iterate id="topic" name="topicsList" scope="request" >
<bean:write name="topic" property="title"/>
</logic resent>

However we are recieveing the following error:
org.apache.jasper.JasperException: Cannot find bean topic in any scope
Marc Peabody
pie sneak

Joined: Feb 05, 2003
Posts: 4727

Your collection probably contains a null value. If so, you'll have to insert another logic:present for topic inside of the iterate tag.

It wouldn't hurt to try out JSTL's c:forEach for your iterations. Once you try it, you probably won't go back to logic:iterate. Just a suggestion.

A good workman is known by his tools.
Eibhlin Reid

Joined: Nov 04, 2004
Posts: 28
Thanks for all your help, as it turned out we were missing a tag at the top of of the JSP!!
I agree. Here's the link:
subject: logic:iterate & DTO Problem
It's not a secret anymore!