Alternating Row colors in tables in Struts

Have to share this one. I’ve been wracking my brain trying to figure out how to get table rows in a struts and JSTL supported page. I haven’t found an easy example anywhere, but I finally sussed it out. So if you do JSTL and struts based stuff, and want to do those nice ‘greenbar’ like lines on a table, here’s an example of how to do it:

<c:forEach var="rows" items="${registrantList}">
<c:set var="cellColor">
<c:when test="${cellColor == '#f0f0f0'}">#ffffcc</c:when>
<s:url id="url" action="coconut/gotoUser" >
<s:param name="rid">${rows.rid}</s:param>
<tr bgcolor="${cellColor}">
<s:a href="%{url}">${rows.rid}</s:a>

See? Simple!


A wandering geek. Toys, shiny things, pursuits and distractions.

View all posts by

Leave a Reply

Your email address will not be published. Required fields are marked *

The reCAPTCHA verification period has expired. Please reload the page.