File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes alternate row color Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "alternate row color" Watch "alternate row color" New topic

alternate row color

arjun rampal
Ranch Hand

Joined: Jul 08, 2005
Posts: 125
Hi I have to make alternate color rows.

now possible solution is below but it is giving one extra line below i dont want to use this.

is there any idea

int num = 0;
String SLATE = "#E4E4E4";
String WHITE = "#FFFFFF";
String bgColor = null;

<logic:iterate id="element" name="dateMap">
if((num % 2) == 0) {
bgColor = SLATE;
} else {
bgColor = WHITE;
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
See Bear Bibeault's solution in this link.

Consultant, Sima Solutions
RoshaniG Gopal
Ranch Hand

Joined: May 15, 2006
Posts: 180

This is one of the ways to make alternate colored rows.

<logic:iterate id="displayresult" name="searchuserForm" property="searchresults" >
<td class="tablecolumndark">
<bean:write name="result" property="firstName"/></td>
<td class="tablecolumnlight">
<bean:write name="displayresult" property="lastName"/></td>

The "tablecolumndark" and "tablecolumnlight" can be defined in the css. I think that should work.

SCJP 1.4

Regards,<br />Roshani
I agree. Here's the link:
subject: alternate row color
jQuery in Action, 3rd edition