This week's giveaways are in the MongoDB and Jobs Discussion forums.
We're giving away four copies of Mongo DB Applied Patterns and 4 resume reviews from Five Year Itch and have the authors/reps on-line!
See this thread and this one for details.
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
Register / Login


Win a copy of Mongo DB Applied Patterns this week in the MongoDB forum
or a resume review from Five Year Itch in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » JSP
Reply 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: 56150
    
  13

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.


[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
Timothy Sam
Ranch Hand

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