struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt <myswt...@hotmail.com>
Subject improving JSP logic
Date Fri, 07 Oct 2005 19:12:42 GMT
I'm plunging into the world of JSP development and I'm
wanting to improve on this type of [messy] logic:

<% int rowCount = 0; %>
<logic:iterate id="oi" name="myForm" property="stuff">
  <% if (++rowCount % 2 == 0) { %>
    <tr class=normalRow>
  <% } else { %>
    <tr class=altRow>
  <% } %>
      <td><bean:write name="oi" property="group3Name" /></td>
  </tr>
</logic:iterate>

My attempts have been various incarnations (for the <tr>) of the
following, utilizing iterate's -indexId-:

<logic:notEmpty name="myForm" property="stuff">
 <logic:iterate id="oi" name="myForm" property="stuff" indexId="idx">
  <tr class=<% (idx.intValue()%2==0) ? "altRow" : "normalRow"; %> >
    <td><bean:write name="oi" property="group3Name" /></td>
  </tr>
</logic:iterate>

Unfortunately, we arent using JSTL (and wont be), otherwise I
could use the solution found here:
http://cephas.net/blog/2004/02/25/jstl_vs_struts_taglib.html

Any suggestions for improvement ? 


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


Mime
View raw message