Reputation: 1346
Below code gives me rows with the same color. How to highlight alternate rows in this table with same color
<logic:iterate id="ulist" name="HomeForm" property="userList">
<tr >
<td class="content"><bean:write name="ulist" property="username" /> </td>
<td class="content"><bean:write name="ulist" property="city" /> </td>
</tr>
</logic:iterate>
Upvotes: 2
Views: 3073
Reputation: 384
Code without scriplet
<logic:iterate id="myData" name="myListFormBean" property="myList" indexId="tableCounter">
<tr class="${tableCounter%2==0 ? 'Even':'Odd'}">
</logic:iterate>
Upvotes: 4
Reputation: 13950
I'm using this code:
<logic:iterate id="myData" name="myListFormBean" property="myList" indexId="tableCounter">
<%
if (tableCounter % 2 == 0) {
tdClass = " white ";
} else {
tdClass = " gray ";
}
%>
<td class="<%=tdClass%>"></td>
</logic:iterate>
Upvotes: 3
Reputation: 12531
You've to assign a differente css
id
for every row, you can use the implicit iterator attributes to obtain that.
Another solution is to use a library like displaytag which automatically adds odd
and even
attributes to the rows, attributes you can use in the css
stylesheet.
Upvotes: 1