Re: iterating over multiple Collections in one loop with JSTL

2006-05-25 Thread David Evans

   ${list1Item}
   ${list2[status.index]}


the status variable is an instance of LoopTagStatus, which has an index
property that is set by the forEach loop.

I might favor combining the two lists (in your action) into a single
list, each element of which has a list that holds the two items from the
lists. so you'd access it like:


   ${listItems[0]}
   ${listItems[1]}



Dave


On Thu, 2006-05-25 at 08:28 -0700, Pat Slater wrote:
> Hi,
> Is it possible to do with JSTL something like this: 
> (Note: size of list1 and list2 are equal)
> List list1 = getList1();
> List list2 = getList2();
> for(int i=0; i {
> MyClass1 x1 = (MyClass1)list1.get( i );
> MyClass2 x2 = (MyClass2)list2.get( i );
> }
> 
> I can iterate with JSTL with forEach for either of the lists separately but I 
> need to display both of them in the same loop. How can I do that?
> 
> 
>   
> -
> Sneak preview the  all-new Yahoo.com. It's not radically different. Just 
> radically better. 


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



RE: iterating over multiple Collections in one loop with JSTL

2006-05-25 Thread Samere, Adam J
How about creating a single list with an object to encapsulate the
values from list1 and list2 in a single entity?

Public class MyClassContainer {
private MyClass1 my1;
private MyClass2 my2;

...
} 

List = ...

myClassContainerList.add(new MyClassContainer(myClass1, myClass2));

Then in the JSP you only need one loop.




...


Adam

-Original Message-
From: Pat Slater [mailto:[EMAIL PROTECTED] 
Sent: Thursday, May 25, 2006 11:28 AM
To: user@struts.apache.org
Subject: iterating over multiple Collections in one loop with JSTL

Hi,
Is it possible to do with JSTL something like this: 
(Note: size of list1 and list2 are equal) List list1 = getList1(); List
list2 = getList2(); for(int i=0; i