Hi, I was hoping someone could point me to an elegant solution for the following.
I have an ArrayList of objects which I use the Iterate tag view, lets say there are 10 objects in it. My requirement is to display the contents of each object in a table cell and have three cells per row. I cant work out an elegant way of wrapping to the next row after every three iterates. At the moment, I get the iterate count and an if scriptlet to see if %3 == 0. If so, I add a </tr><tr>. Then when the iterate has finished, I need to check the mod again with an if scriptlet and add extra <TD></TD> tags on the end before the closing </tr>. I have put the code snippet below. The annoying thing is the extra amount of work if I move to 4 columns... Any help with doing this using struts tags would be appreciated as would design pointers on coding my own tag or tag set. Regards, Chris. <%-- Scriptlet 0 - hold the idx value from iterate outside iterate scope --%> <% int iterateIdx = 0; %> <logic:iterate id="foo" name="fooList" indexId="idx"> <%-- Scriptlet 1 - List foo 3 abreast --%> <% iterateIdx = idx.intValue(); %> <% if (idx.intValue() % 3 == 0) { %> <tr> <td colspan="3"><hr></td> </tr> <tr> <% } // End if %> <%-- End Scriptlet 1 --%> <td width="33%"> <table> <tr> <td> <bean:write name="foo" property="bar"/> </td> </tr> <tr> <td> <html:link page="/anAction.do" paramId="fooId" paramName="foo" paramProperty="bar_id"> <app:img name="foo" property="barImgPath"/> </html:link> </td> </tr> </table> </td> <%-- Scriptlet 2 - List artwork 3 abreast --%> <% if (idx.intValue() % 3 == 2) { %> </tr> <% } // End if %> <%-- End Scriptlet 2 --%> </logic:iterate> <%-- Scriptlet 3 - Tidy up --%> <% if (iterateIdx % 3 == 0) { %> <td> </td> <td> </td> </tr> <% } else if (iterateIdx % 3 == 1) { %> <td> </td> </tr> <% } %> <%-- End Scriptlet 3 --%> -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: 27 February 2002 14:17 To: [EMAIL PROTECTED] Subject: RE: speed of struts I'm interested in hearing other opinion on this. I personally find the logic present/equals tags to be ugly and cumbersome (not to mention inefficient in terms of the generated servlet) and often find myself resorting to simple if/else scriptlets instead. I'm not sure the logic tags win even from a maintainabilit point of view. How does everyone else deal with complex display logic? Do you use the logic tags? -----Original Message----- From: Jim Downing [mailto:[EMAIL PROTECTED]] Sent: Wednesday, February 27, 2002 8:17 AM To: Struts Users Mailing List Subject: Re: speed of struts On Mon, Feb 11, 2002 at 03:01:12PM +0000, [EMAIL PROTECTED] wrote: > I'm curious as to the limit here. I'm currently building an app which > has huge form requirements - I may have upwards of 500 fields as html > text inputs -- very spreadsheet like. Where is the limitation? > Rendering into html, or parsing the request into beans? I've had not > problems so far with rendering speed, though I'm using Mozilla, so > browser speed hasn't been noticable to far.. I've just finished a struts project where I had to move to scriptlets away from struts tags for presentation logic. The problem was that every now and then the GC would take a second or so to run. This struck me as a VM issue (and may still have been, although it happened under linux jdk1.2.2 and 1.3.1), but when I profiled the page I found that the handful of tags I was using (10 - 20 logic equals, a few logic:iterates) were generating 6M of garbage. Is this typical for all taglibs? I dislike developing with scriptlets, but that's a pretty big performance hit to have to take for a bit of maintainability. Is this the same factor that limits pages to 50 form tags? What's the best solution for pages with complex presentation logic? jim Jim Downing [EMAIL PROTECTED] -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>