You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Paap, Keith" <Ke...@westgroup.com> on 2001/09/21 22:06:45 UTC

nested iterate using indexed value from outer iterate?

We're having some difficulty tracking down how we could use the value on the
bean in an iterate loop could be used in a next iterate.  Here's the
example:

<logic:iterate id="category_row" name="def_categories" type="bean.Category"
property="categories"> 
	<%-- some category header html goes here --%>
	<logic:iterate id="trait_row" name="personalinfo"
property="Traits[x]">
		<%-- some html goes here related to each trait of the given
category --%>
	</logic:iterate>
</logic:iterate>

The problem is that there is a method "getId()" on the Category class and
that is the indexed value I want to pass as "x" in the property="Traits[x]"
statement.  I can do a bean:write to get the property out of the individual
Category instances but how do I get that into an expression for the nested
iterate?

As a bonus question I set up the Category bean with an attribute name of
"def_categories" using a jsp:useBean to actually instantiate the bean (wait
before you comment on that).  What I would prefer to do is change the
getCategories() method on the Category class to a static method and capture
the array of Category and iterate through it.  Any thoughts how that could
be done would also be appreciated.

TIA, 

Keith Paap