aspose file tools*
The moose likes JSP and the fly likes foreach, showing a list  like  a matrix Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "foreach, showing a list  like  a matrix" Watch "foreach, showing a list  like  a matrix" New topic
Author

foreach, showing a list like a matrix

Danny Garcia
Greenhorn

Joined: Feb 05, 2005
Posts: 3
Hi, i have a list like this,

products = (product01,product02,product03,product04,product05,product06)

And i need show this list like a matrix

product01 product02 product03
product04 product05 product06

I�m using jstl and foreach but i dont know how to solve this problem.

Any hints
Thank
Danny
[ January 03, 2006: Message edited by: Danny Garcia ]
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Assuming product01, product02, etc are proper beans with getter methods for their properties, you could do something like this:


In this case "activeUsers" is a list of User beans.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Danny Garcia
Greenhorn

Joined: Feb 05, 2005
Posts: 3
Hi Ben, that is not a solutions to my problem. In your solution you are showing activelist like list (one row for one user). I need to show the same activelist like a matrix.

activelist[1].name activelist[2].name activelist[3].name
activelist[4].name activelist[5].name activelist[6].name

Thanks
Danny
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

Use a loop status to check if you have reach the matrix length



[My Blog]
All roads lead to JavaRanch
 
 
subject: foreach, showing a list like a matrix