• 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

Arranging list data

 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Oops - here's the code, formatted a little better . . .
 
Ranch Hand
Posts: 948
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
reply
    Bookmark Topic Watch Topic
  • New Topic