RE: logic:iterate multiple collections

2005-05-24 Thread Pushkala_Iyer
 
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
   tdbean:write name=myOuterMap property=key//td
   logic:iterate id=myInnerMap name=myForm property=myInnerMap
tdbean: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,
   tdbean: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]



Re: logic:iterate multiple collections

2005-05-24 Thread Wendy Smoak
From: [EMAIL PROTECTED]

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

 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.

c:forEach var=outerMapEntry items=${outerMap}
c:out value=${outerMapEntry.key}/
c:forEach var=innerMapEntry items=${outerMapEntry.value} 
  c:out value=${innerMapEntry.value}/
/c:forEach
/c:forEach

See http://wiki.wendysmoak.com/cgi-bin/wiki.pl?JSTLNestedMapIterate for test
code.

-- 
Wendy Smoak



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



RE: logic:iterate multiple collections

2005-05-24 Thread Pushkala_Iyer

Thanks! That worked, and is also much easier to understand.

This is probably a newbie question: How / when does one choose between
using JSTL / Struts Tags? 
Is there any reason to choose Struts tags over JSTL?

Thanks,
PS

-Original Message-
From: Wendy Smoak [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, May 24, 2005 11:02 AM
To: Struts Users Mailing List
Subject: Re: logic:iterate multiple collections

From: [EMAIL PROTECTED]

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

 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.

c:forEach var=outerMapEntry items=${outerMap}
c:out value=${outerMapEntry.key}/
c:forEach var=innerMapEntry items=${outerMapEntry.value} 
  c:out value=${innerMapEntry.value}/
/c:forEach
/c:forEach

See http://wiki.wendysmoak.com/cgi-bin/wiki.pl?JSTLNestedMapIterate for
test code.

--
Wendy Smoak




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



Re: logic:iterate multiple collections

2005-05-24 Thread Jeff Beal
See http://struts.apache.org/faqs/struts-el.html.  It includes a list
of Struts tags whose functionality is covered by the JSTL.

On 5/24/05, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
 
 Thanks! That worked, and is also much easier to understand.
 
 This is probably a newbie question: How / when does one choose between
 using JSTL / Struts Tags?
 Is there any reason to choose Struts tags over JSTL?
 
 Thanks,
 PS


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



Re: logic:iterate multiple collections

2005-05-23 Thread Wendy Smoak
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]