• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Timothy Sam
Ranch Hand
Posts: 751
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64718
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Timothy Sam
Ranch Hand
Posts: 751
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That was nice! Thanks!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic