A related question, so I thought I'll post it to this thread.

The data structure I use is a HashMap, whose values are other HashMaps.
Like so:

OuterMap
OuterKey1: InnerMap1
           InnerKey11: Value11
           InnerKey12: Value12  
OuterKey2: InnerMap2
           InnerKey21: Value21
           InnerKey22: Value22  

I'm trying to nest two logic:iterate tags to print out the keys in the
outer map and the values in the inner Map. 

What I'm trying to do is something like this:

<logic:iterate id="myOuterMap" name="myForm" property="myOuterMap">
<tr>
   <td><bean:write name="myOuterMap" property="key"/></td>
   <logic:iterate id="myInnerMap" name="myForm" property="myInnerMap">
            <td><bean:write name="myInnerMap" property="value"/></td>   
   </logic:iterate>   
</tr>
</logic:iterate>

This has a problem, because, it needs the innerMap attribute set in the
request - however, this always gets the same value, probably because of
the way I'm setting it in my Action. 

1) I probably need a list of innerMaps in my form, but I'm not sure how
to do this.

2) If I try to print the value using the outerMap alone, like so,
   <td><bean:write name="MyOuterMap" property="value"/></td>  I'm not
sure how I can format this in the way that only the values are seen. 

Does anyone have any pointers?

Thanks,
PS

-----Original Message-----
From: Wendy Smoak [mailto:[EMAIL PROTECTED] 
Sent: Monday, May 23, 2005 6:42 PM
To: Struts Users Mailing List
Subject: Re: logic:iterate multiple collections

From: "Titus Barik" <[EMAIL PROTECTED]>
>
> Let's say I have two collections, A, and B. Is there a way to iterate 
> over multiple collections with something like logic:iterate?
>

If you know they're the same size and in the same order, (should be the
case with List,) how about iterating over one with <c:forEach
varStatus="status"> and using ${status.count} to address the second
List.

Can you change the design?  If the items in both collections really
belong together, try to store them together so you don't have to jump
through hoops like this.

--
Wendy Smoak



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

Reply via email to