I have a RowTag that does this, it generates <tr> elements and you can
specify either oddColor/evenColor attributes to generate bgcolor= attributes
or oddStyle/evenStyle parameters to generate class= attributes for CSS.

So the jsp looks like this:

  <table>
    <logic:iterate id=".." name=".." property="..">
       <util:row oddColor="#C0C0C0" evenColor="#FF0000">
                <td>.....</td>
                <td>.....</td>
       </util:row>
    </logic:iterate>
  </table>

You can either specify both odd and even or just one of them.

I'll send it if you're interested.

Niall


> -----Original Message-----
> From: Bill Pfeiffer [mailto:[EMAIL PROTECTED]]
> Sent: 11 May 2001 20:08
> To: Struts-User
> Subject: Determining odd-even table rows
>
>
> I'm trying to figure out how to do a green-bar effect (different backround
> colors for every other row of a table) with struts/jsp.  I am using a
> tagified javax.sql.Rowset.  I can iterate through the rowset via my tags
> (reworked jakarta DBTags).  The problem, more of a mental block,
> is how do I
> alternate the backround colors of the html rows I am writing WITHOUT
> resorting to scriptlets.  I have just added a tag to get the
> current row, so
> I have that returing, but what do I do with it?
>
> The logic tags in struts deal only with comparisons to constants.
>  I need to
> do some math to determine whether the current row is odd/even so I can set
> the backround.
>
> Is it easier than this and I'm missing it?
>
> My goal here is not to do any scriplets.  I'm putting together a
> set of tags
> to help our web guy build pages using only tags.
>
> Thanks for any help,
>
> Bill Pfeiffer
>
>

Reply via email to