• 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
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

Logic:iterate How to break the loop for a certain value in collection

 
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Guys,
i have a collection(IDRequirements) of size 12 that i am iterating. What i am trying to do is to break this collection into multiples of 4 and show it in three different columns of a table. As you can see from the code below i am having all of them displayed in one column of a table.

I am wondering if there is some way to set this offset value in logic:iterate so that i can dynamically generate a columns with 4 check boxes in each(In my case). I do not want to reinvent wheel by writing my own tab library to do this if something like this can be done using Struts tags someway.

Guys Appreciate your help.


<td height="24" width="25%" class="odd">

<logic:iterate id="IDRequirement" name="InitialPageDetailViewBean" property="IDRequirements">


<html:multibox property="IDRequiredValues">
<bean:write name="IDRequirement" property="value"/>
</html:multibox>
<bean:write name="IDRequirement" property="label"/><br/>
</logic:iterate>

</td>
 
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This works pretty well... unless you've a bad case of scriptletphobia.

<td height="24" width="25%" class="odd">
<% int count = 0; %>
<logic:iterate id="IDRequirement" name="InitialPageDetailViewBean" property="IDRequirements">
<% if(count++ % 4 == 0){ %>
</td>
<td height="24" width="25%" class="odd">
<% } %>
<html:multibox property="IDRequiredValues">
<bean:write name="IDRequirement" property="value"/>
</html:multibox>
<bean:write name="IDRequirement" property="label"/><br/>


</logic:iterate>

</td>
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic