You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Kishore Senji <ks...@gmail.com> on 2005/01/27 08:26:19 UTC

Re: Advise How to set alternative raow background color

On Thu, 27 Jan 2005 12:49:00 +0530, senthil Kumar
<se...@tarangtech.com> wrote:
> Hi all.
> 
>  I am getting more than 100 regards from database and print in a JSP by 15 regards per Page.
>  Its is working fine.
>  Now i want to set alternative Row background color. I print all the rows between the <logic:iterator> in
> Struts. any one help me.
> 
> Here i am putting my code also.
> welcome anyone to give correct code also,
> 
> <logic:iterate id="collection" name="DFThreadForm" scope="session" property="selectRegsList" >
>                          <tr bgcolor="#c2c2c2">

 <logic:iterate id="collection" name="DFThreadForm" scope="session"
property="selectRegsList" indexId="index">
                            <tr
bgcolor='<%=index.intValue()%2==0?"#c2c2c2":"#d2d2d2"%>'



>       <td align="left">
>         <a href="ShowThread.do?messageId=<bean:write name="collection" property="messageId"/>">
>           <bean:write name="collection" property="topic"/>
>         </a>
>       </td>
>     <td align="center">
>     <bean:write name="DFThreadForm" property="projectName"/>
> 
>       </td>
>          <td align="center"><bean:write name="collection" property="enteredDate"/></td>
>      </tr>
>   </logic:iterate>
> 
> Thanks in Advance
> 
> Regs.,
> senthil
> 
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Advise How to set alternative raow background color

Posted by Eddie Bush <ea...@gmail.com>.
I avoid runtime expressions and scriplets as much as I can:

<c:forEach values="myList" item="var" varStatus="status">
  <c:choose>
    <c:when test="${ (status.count % 2) == 0 }">
      <%-- White BG --%>
      <tr class="rowEven">
      ...
    </c:when>
    <c:otherwise>
      <%-- Grey BG --%>
      <tr class="rowOdd">
      ...
    </c:otherwise>
    <td>...</td>
    </tr>
  </c:choose>
</c:forEach>

Y'all would do well to use the JSTL where you can.  The documentation
for the Struts taglibs even says that.

-- 
Eddie Bush

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Advise How to set alternative raow background color

Posted by Jeff Beal <jb...@webmedx.com>.

Kishore Senji wrote:
> On Thu, 27 Jan 2005 12:49:00 +0530, senthil Kumar
> <se...@tarangtech.com> wrote:
> 
>>Hi all.
>>
>> I am getting more than 100 regards from database and print in a JSP by 15 regards per Page.
>> Its is working fine.
>> Now i want to set alternative Row background color. I print all the rows between the <logic:iterator> in
>>Struts. any one help me.
>>
>>Here i am putting my code also.
>>welcome anyone to give correct code also,
>>
>><logic:iterate id="collection" name="DFThreadForm" scope="session" property="selectRegsList" >
>>                         <tr bgcolor="#c2c2c2">
> 
> 
>  <logic:iterate id="collection" name="DFThreadForm" scope="session"
> property="selectRegsList" indexId="index">
>                             <tr
> bgcolor='<%=index.intValue()%2==0?"#c2c2c2":"#d2d2d2"%>'

Instead of setting bgcolor, set the class attribute:

class='<%= index.intValue()%2 == 0 ? "event" : "odd"%>

That way, you can use CSS to change the color easily on all of your 
pages at once.

tr.even {  background-color: #C2C2C2; }
tr.odd { background-color: #D2D2D2; }

-- Jeff


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Advise How to set alternative raow background color

Posted by Cedric Levieux <jo...@gmail.com>.
Personnaly for this kind of stuff i've got my own tag that have the hability
to iterate and to cycle over given values.

----- Original Message ----- 
From: "Kishore Senji" <ks...@gmail.com>
To: "Struts Users Mailing List" <us...@struts.apache.org>
Sent: Thursday, January 27, 2005 8:26 AM
Subject: Re: Advise How to set alternative raow background color


> On Thu, 27 Jan 2005 12:49:00 +0530, senthil Kumar
> <se...@tarangtech.com> wrote:
> > Hi all.
> >
> >  I am getting more than 100 regards from database and print in a JSP by
15 regards per Page.
> >  Its is working fine.
> >  Now i want to set alternative Row background color. I print all the
rows between the <logic:iterator> in
> > Struts. any one help me.
> >
> > Here i am putting my code also.
> > welcome anyone to give correct code also,
> >
> > <logic:iterate id="collection" name="DFThreadForm" scope="session"
property="selectRegsList" >
> >                          <tr bgcolor="#c2c2c2">
>
>  <logic:iterate id="collection" name="DFThreadForm" scope="session"
> property="selectRegsList" indexId="index">
>                             <tr
> bgcolor='<%=index.intValue()%2==0?"#c2c2c2":"#d2d2d2"%>'
>
>
>
> >       <td align="left">
> >         <a href="ShowThread.do?messageId=<bean:write name="collection"
property="messageId"/>">
> >           <bean:write name="collection" property="topic"/>
> >         </a>
> >       </td>
> >     <td align="center">
> >     <bean:write name="DFThreadForm" property="projectName"/>
> >
> >       </td>
> >          <td align="center"><bean:write name="collection"
property="enteredDate"/></td>
> >      </tr>
> >   </logic:iterate>
> >
> > Thanks in Advance
> >
> > Regs.,
> > senthil
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org