Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Arranging list data

 
Dave Mere
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there,

I have a set of results returned to my jsp as a list of beans. Each bean contains one data field and the name of a thumbnail to find and display. The info needs to be displayed in a fixed table format, like so:

1 2 3 4 5
6 7 8 9 10

I can think of a few ways to acheieve this. For example, set an arbitary variable i to increment with each new record. When i = 6 add another <tr>.
Or, return the results as two sets of 5 and loop through the <logic:iterate> twice so I have two tables.

But both of these seem like applying sticking plasters to a problem that I should really solve! Can anyone suggest a better way of arranging these records in the above format?

Thanks, Dave
[ February 21, 2006: Message edited by: Dave Mere ]
 
Dave Mere
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oops - here's the code, formatted a little better . . .
 
Brent Sterling
Ranch Hand
Posts: 948
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dave: Don't sweat the small stuff. Either of your proposed solutions sounds fine to me. This is presentation logic since all you are doing is displaying data on the page. I would implement this in either the JSP or in my Action Form class.

- Brent
 
Dave Mere
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One of my colleagues gave me the same answer. It works doesn't it? Then do it! Perhaps I'm starting to think too much.

cheers brent
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you want this to work for any number of entries (not just 10 or less) you might consider changing the logic to :

if ((currentIndex % 5) == 0)
... add a new row
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic