• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

question abut logic:iterate tag

 
John Smith
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a collection that might contain 5 or 7 values. it might vary, but I want them to display in 3 rows by 3 columns by using iteration tag. so the tricky thing is that I don't know how to put "<br>" after each 3rd and 6th value. I am just wondering if it is possible to use it with Struts' currently existing tags or I have to create my own tags.

Thanks..
 
sanat
Ranch Hand
Posts: 111
Eclipse IDE Java Mac
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think this can be achieved using <logic:iterate> and <logic:equals>.
Here basically you have to check for the index number of the element and if index%3=1 you can insert one line break.
 
Franck Tranchant
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

As Sanat Kumar Padhy previously said, you won't have to create your own tags for this.
The only thing is, as far I as know, you propably won't be able to manage this 100% with Struts. You will need a little bit of Java in your JSP.

For example :will give you access to any data of your collection plus an indexId wich will be useful to know where you are in your iteration.

Then, while iterating on your data, a simple Java code such aswill give you the control of your table structure.

Note : Pay attention, the indexId value may be zero based

PS: If someone know how do that without any Java code, only with Struts tags, please let us know.
[ March 15, 2005: Message edited by: Franck Tranchant ]
 
John Smith
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
great, thanks.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic