This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
The moose likes Struts and the fly likes Struts Iterator Query Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts Iterator Query" Watch "Struts Iterator Query" New topic

Struts Iterator Query

terry phillips

Joined: Sep 09, 2006
Posts: 1
Struts 1.1.
Java 1.5
Tomcat 5.5.9


I'm really struggling with an embeded logic:iterate tag, and was hoping someone could point me in the right direction.

what I'm trying to achieve is the following

retrieve all products from by db for a selected subcategory.
display every product on the jsp, i.e. iterate through the 'ProductList' in the request.
for each product provide a selection box containing all it's size options (product_size_array property of the Product object)

I have the following but it isn't correct as no product sizes are being printed out, although the OUTER iterator is running fine as the name details for each product can be printed no problems.

<!--Iterate around all products in the ProductList LinkedHashSet-->
<logic:iterate id="Product" name="ProductsList" type="net.domain.Product" scope="request">

<!--For each product Iterate through it's product_size_array property which is a LinkedHashSet containing String objects-->
<select name="product_size" size="1">
<logic:iterate id="product_size" name="Product" property="product_size_array" type="java.lang.String">
<option value="<bean:write name='product_size'/>"><bean:write name="product_size"/></option>


Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63547

Welcome to the Ranch.

We have a forum dedicated to Struts questions to which this post has been moved.

[Asking smart questions] [About Bear] [Books by Bear]
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
I'd suggest using the <htmlptions> tag rather than <logic:iterate>. The <logicptions> tag renders all the options in a collection. Here is a link to the documentation.
[ September 09, 2006: Message edited by: Merrill Higginson ]

Consultant, Sima Solutions
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: Struts Iterator Query
It's not a secret anymore!