GeeCON Prague 2014*
The moose likes Struts and the fly likes struts2 struts-tags iteration question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Frameworks » Struts
Bookmark "struts2 struts-tags iteration question" Watch "struts2 struts-tags iteration question" New topic
Author

struts2 struts-tags iteration question

Kevin P Smith
Ranch Hand

Joined: Feb 18, 2005
Posts: 362
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

Joined: Aug 01, 2007
Posts: 485

<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


ocjp 6 — Feeding a person with food is a great thing in this world. Feeding the same person by transferring the knowledge is far more better thing. The reason is the amount of satisfaction which we get through food is of only one minute or two. But the satisfaction which we can get through the knowledge is of life long.
Kevin P Smith
Ranch Hand

Joined: Feb 18, 2005
Posts: 362
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
 
GeeCON Prague 2014
 
subject: struts2 struts-tags iteration question