This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes Struts and the fly likes Struts iterate tag and formatting Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts iterate tag and formatting" Watch "Struts iterate tag and formatting" New topic
Author

Struts iterate tag and formatting

david allen
Ranch Hand

Joined: Sep 27, 2002
Posts: 185
Hi all,

I have returned a collection of objects and am using the iterate tag to loop through them and display there names in a table.

However, intsead of displaying them like this:
onject 1
object 2
object 3
object 4

I would like to display them as this

object 1 object 2
object 3 object 4

Does anyone know of a good way of doing this?

Is there anyway you can specify if commands in the iterate tag and access the counter used by the tag?
This way I could test the following

if(counter mod 2 == 0) then insert new row

thank you

david
Junilu Lacar
Bartender

Joined: Feb 26, 2001
Posts: 4419
    
    5

I suggest moving to JSTL.



Also see this: http://www-106.ibm.com/developerworks/java/library/j-jstl0318/


Junilu - [How to Ask Questions] [How to Answer Questions]
John Smith
Ranch Hand

Joined: Sep 02, 2004
Posts: 61
yeah the jstl c:forEach works or you can use the index attribute in your current logic:iterate, you can do your mod test on that
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Struts iterate tag and formatting
 
Similar Threads
whats wrong with my code ?
question regarding iterating Property class
Something i'm extremely confused on
for loop question
Using compareTo in a Loop