You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by mt <my...@hotmail.com> on 2005/10/07 21:12:42 UTC
improving JSP logic
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