This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "logic:iterate & DTO Problem" Watch "logic:iterate & DTO Problem" New topic
Author

logic:iterate & DTO Problem

Eibhlin Reid
Greenhorn

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:



or

Eibhlin Reid
Greenhorn

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:iterate><br>
</logic resent>

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

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
Greenhorn

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: http://aspose.com/file-tools
 
subject: logic:iterate & DTO Problem
 
Similar Threads
Displaying ResultSets in View
dynamic logic:iterate
for loop in select struts tag
html:messages does not display messages
Array dispaly