• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

question abut logic:iterate tag

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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..
 
Ranch Hand
Posts: 111
Mac Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
great, thanks.
reply
    Bookmark Topic Watch Topic
  • New Topic