File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes Logic:iterate How to break the loop for a certain value in collection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Logic:iterate How to break the loop for a certain value in collection" Watch "Logic:iterate How to break the loop for a certain value in collection" New topic
Author

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

vikram nalagampalli
Ranch Hand

Joined: Oct 08, 2001
Posts: 91
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>
Marc Peabody
pie sneak
Sheriff

Joined: Feb 05, 2003
Posts: 4727

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>


A good workman is known by his tools.
 
 
subject: Logic:iterate How to break the loop for a certain value in collection
 
Similar Threads
Iterating for non-collection object
Multibox Not Populating as Checked!!!
help with html radio tag
On htm:multibox
bean:define not working in logic:iterate