You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Michael Mok <mi...@consultech.net.au> on 2000/11/01 03:07:10 UTC

Alternating colors for rows displayed?

Hi,

I am using the <logic:iterate> tag to loop through my SQL query result and
displaying them. Is there a way to display the rows such that they are
displayed with different colors (eg odd rows blue even rows red)?

I thought of coding additional java code in the JSP page to sett the color
of the row (I am displaying my rows in a HTML
<table><tr><td></td></tr></table>)within the <logic:iterate>.

Maybe an enhancement can be made to the <struts:logic> tag to take a style
sheet setting for specifying a row color combination of some sort or a new
<struts:logic-table> tag for displaying collections.

Any opinion?

Michael Mok


Re: Alternating colors for rows displayed?

Posted by Bob Sullivan <su...@dotech.com>.
you might want to check out JSPTags.com's Pager tag library. They have about 4
different flavors of displays to allow just sort of a presentation effect.

I haven't used it in anything real, so I can't speak to the quality or
robustness (but it sure looks pretty :)

Bob

Andrew Semprebon wrote:

> Philosophically, I think this belongs in the JSP rather than the taglib,
> since it is part of the presentation, and its pretty trivial to do with a
> scriptlet. Maybe if you are doing it on a lot of pages it might be worth
> putting in a custom taglib for reusibility.
>
> ----- Original Message -----
> From: "Michael Mok" <mi...@consultech.net.au>
> To: <st...@jakarta.apache.org>
> Sent: Tuesday, October 31, 2000 9:07 PM
> Subject: Alternating colors for rows displayed?
>
> > Hi,
> >
> > I am using the <logic:iterate> tag to loop through my SQL query result and
> > displaying them. Is there a way to display the rows such that they are
> > displayed with different colors (eg odd rows blue even rows red)?
> >
> > I thought of coding additional java code in the JSP page to sett the color
> > of the row (I am displaying my rows in a HTML
> > <table><tr><td></td></tr></table>)within the <logic:iterate>.
> >
> > Maybe an enhancement can be made to the <struts:logic> tag to take a style
> > sheet setting for specifying a row color combination of some sort or a new
> > <struts:logic-table> tag for displaying collections.
> >
> > Any opinion?
> >
> > Michael Mok
> >


Re: Alternating colors for rows displayed?

Posted by Andrew Semprebon <se...@eqsystems.com>.
Philosophically, I think this belongs in the JSP rather than the taglib,
since it is part of the presentation, and its pretty trivial to do with a
scriptlet. Maybe if you are doing it on a lot of pages it might be worth
putting in a custom taglib for reusibility.

----- Original Message -----
From: "Michael Mok" <mi...@consultech.net.au>
To: <st...@jakarta.apache.org>
Sent: Tuesday, October 31, 2000 9:07 PM
Subject: Alternating colors for rows displayed?


> Hi,
>
> I am using the <logic:iterate> tag to loop through my SQL query result and
> displaying them. Is there a way to display the rows such that they are
> displayed with different colors (eg odd rows blue even rows red)?
>
> I thought of coding additional java code in the JSP page to sett the color
> of the row (I am displaying my rows in a HTML
> <table><tr><td></td></tr></table>)within the <logic:iterate>.
>
> Maybe an enhancement can be made to the <struts:logic> tag to take a style
> sheet setting for specifying a row color combination of some sort or a new
> <struts:logic-table> tag for displaying collections.
>
> Any opinion?
>
> Michael Mok
>


Re: Alternating colors for rows displayed?

Posted by Julia Reynolds <ju...@healthstream.com>.
Here's what I have done:

out.println("<table cellspacing=0 cellpadding=0 width=600>");
  int row = 1;
  String color = "";
   while(rec.next())
   {
    if((row%2)==0)
   {
    color = "white";
   }
   else
    color = "DDDDDD";

    out.println("<tr bgcolor="  + color + "><td ><a href=" +
rec.getString("URL") + "" + " target=\"_blank\"" + ">" +
rec.getString("Description") + "</a></td><td>  Category:  "
    + rec.getString("CatName") + "<br></td></tr>");
    row++;
   }
   out.println("</table>");

It's not beautiful, but it works.

JJR

Michael Mok wrote:

> Hi,
>
> I am using the <logic:iterate> tag to loop through my SQL query result and
> displaying them. Is there a way to display the rows such that they are
> displayed with different colors (eg odd rows blue even rows red)?
>
> I thought of coding additional java code in the JSP page to sett the color
> of the row (I am displaying my rows in a HTML
> <table><tr><td></td></tr></table>)within the <logic:iterate>.
>
> Maybe an enhancement can be made to the <struts:logic> tag to take a style
> sheet setting for specifying a row color combination of some sort or a new
> <struts:logic-table> tag for displaying collections.
>
> Any opinion?
>
> Michael Mok

--
  H e a l t h S t r e a m,   I n c.
  Julia Reynolds - Systems Developer
  209 10th Ave. South Ste. 450 - Nashville, TN 37203
  phone: (615) 301-3220 - fax: (615) 301-3200

  email: Julia.Reynolds@HealthStream.com
  Web Site: http://www.cmecourses.com