I am using the Struts iterator tag and trying to get 3 elements of my list in 1 iteration.
This is what I have.
<s:iterator status="stat" value="(secondResultSet.size()/3).{ #this}" >
<s:property value="#stat.count" /> <!-- Note that "count" is 1-based, "index" is 0-based. -->
<s:property value="%{secondResultSet.get(#stat.index).altId}"/>
<s:property value="%{secondResultSet.get(#stat.index+1).altId}"/>
<s:property value="%{secondResultSet.get(#stat.index+2).altId}"/>
</s:iterator>
my list has 18 elements and in a single iteration I want to print out 3 elements. Thats why I am dividing the length of list by 3. So loop will run 6 times…in total printing out 18 elements.
For this example different altId my list contains are: 41 – 58 (18). However, the code I have prints out the following
First Iteration: 41 42 43
Second Iteration: 42 43 44
Third Iteration: 43 44 45
So it seems like the counter is not getting updated. Can someone help me with this?
for someone else trying to do this…
Best way is to create the list in your class like so:
and then use s:iterator tag like so: