Subject: Re: Producing alternating background colours in struts in a table
From: [EMAIL PROTECTED] (Dalibor42)
 ===
[EMAIL PROTECTED] wrote in <[EMAIL PROTECTED]>: 

>I have a list I am printing out and would like to alternate the 
>background colour between each item in the list between light blue and 
>light grey.  The list is not in a table at the moment, but if this is 
>the best way to go I can put it in a table.  What is the best way to 
>acheive this.  The list is currently getting generated in a 
><logic:iterate> tag.

Use your own bean:

        <jsp:useBean id="color" class="your.color.bean">

Set you colors with:

        <jsp:setProperty name="color" property="color1" value="#d7ddf3"/>
        <jsp:setProperty name="color" property="color2" value="#eef2fb"/>

And change background where you need with:

        <tr bgcolor='<jsp:getProperty name="color" property="nextColor"/>'>

your.color.bean looks like this:

        private String color1="white";  // default color
        private String color2="yellow"; // default color
        private boolean which = false;
        public void setColor1(String color) { color1 = color; }
        public void setColor2(String color) { color2 = color; }
        public String getColor() { return which ? color1 : color2; }
        public String getNextColor() { which = !which; return getColor(); }

-- 
e-mail: [EMAIL PROTECTED]
emajl : [EMAIL PROTECTED]
ICQ # : 129068041
phone : 1ABACA@098

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to