I having a doubt regarding accessing an array of arraylist in jsp using iterator tag.
In my action class i used the following codes..,
ArrayList[] arr= new ArrayList[10];
for(int i = 0; i < 10; i++) {
arr[i] = new ArrayList<bean>();
}
while (some conditions) {
arr[i].add(new bean(some values));
i++;
}
My question is.. how can i access the arr[0],arr[1]…arr[n] arraylists in iterator..?
The following code is working perfectly.., but please improve it to achieve my result..!
<s:iterator value="display.arr[0]">
...
</s:iterator>
Helps will be appreciated..!
I’m wondering if you looked at the iterator tag documention much; there are at least 3-4 ways to go about doing this, including using an immediate list of indexes, using the
"begin"/"end"attributes, using"var"to hold the outer item (not strictly necessary, but IMO it’s more communicative), etc.Assume a property named
"s"in the bean class, which I callSomeBean:Using the Java code at the bottom, this produces the following output:
The complete action driving this code; I just return a new list every time as an example:
Note the SO policy on accepting answers. Normally I wouldn’t bring it up to a new user, but IMO I expended more effort answering this question than you did researching it, which makes me depressed.