File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes Alternating color of table rows in a forEach tag (JSTL) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Alternating color of table rows in a forEach tag (JSTL)" Watch "Alternating color of table rows in a forEach tag (JSTL)" New topic
Author

Alternating color of table rows in a forEach tag (JSTL)

Timothy Sam
Ranch Hand

Joined: Sep 18, 2005
Posts: 746
Hi, I got this forEach loop



where userslist is a javabean and records a field containing the list of beans. Now when I do this...




this makes an alternating color of rows. However, the userId's doesn't always come in order of 123456. So I was thinking of another solution. You guys have any other ideas? Thanks!


SCJP 1.5
http://devpinoy.org/blogs/lamia/ - http://everypesocounts.com/
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60782
    
  65

Shouldn't you be using the loop counter for this? Using the userId is just, well, plain weird.

To access the loop counter, investigate the varStatus attribute of forEach.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Timothy Sam
Ranch Hand

Joined: Sep 18, 2005
Posts: 746
That was nice! Thanks!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Alternating color of table rows in a forEach tag (JSTL)
 
Similar Threads
Iteration of List in JSP
JSTL when test problem
confusion in running an simple jstl application
Geting a Cell Content Value
Using Two ArrayLists For One Table