• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

struts2 struts-tags iteration question

 
Kevin P Smith
Ranch Hand
Posts: 362
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I'm trying to create a grid of images using struts-tags, which starts a new line every 4 images (1,2,3,4 new line 5,6,7,8 new line 9...)
I did a similar thing ages ago using standard JSTL, but now we are just using struts-tags.
I have tried to implement the issue in the same way and have the below code, bit the var 'count' is not getting set the images are never going to a second line.

Could anyone point me in the right direction?....

 
Mohana Rao Sv
Ranch Hand
Posts: 485
Eclipse IDE Firefox Browser Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<s:if test="#imagesList.odd == true "> use like this.

for more detail refer the link http://struts.apache.org/2.0.14/docs/iterator.html
 
Kevin P Smith
Ranch Hand
Posts: 362
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sort of, but that would give me every other item in the list (I believe there is a .even argument as well). What I want to do is every 4th (or 5th) item; so that I can create a 'grid' of images

img1 img2 img3 img4
img5 img6 img7 img8
img9...


So something like

counter++
if(counter >4)
counter = 1
</tr><tr>


So everytime the counter gets to 5, we create a new line and reset the counter.

I've done it in standard JSTL, but do not know how/if you can do it with struts2 /struts-tags

Cheers
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic