I've searched trying to answer this one so would really appreciate some help to what is probably very simple! I'm iterating through an array of objects. One of the fields in these objects is the 'group' to which the object belongs (the objects are ordered by this value). I want to format my HTML according to when the 'group' value changes. Here's the basics:
<logic:iterate id="feature" name="adSearchFeatures" indexId="count"> <logic:notEqual name="feature" property="group" value="<%=lastGroup%>"> <b><bean:write name="feature" property="group"/></b> </logic:notEqual> <html:checkbox property="name" name="feature"><bean:write name="feature" property="name"/></html:checkbox> <!--NEED TO SET THE lastGroup HERE IN ORDER TO COMPARE ABOVE???--> </logic:iterate>
If I can access the current 'feature' in the iteration by breaking into java that will do it as I can set a variable there, but I haven't been able to figure out how to access 'getGroup()' or 'group'.
Hope someone can help.
Rob [ September 03, 2008: Message edited by: Rob CB ]
Joined: Sep 02, 2008
Managed to solve this this morning.
Declared a variable before the iteration:
Then set the value within the iteration:
which I had already tried and failed. However, realised that you need to set the Type in the iterate tag to the type of object that is being iterated over. This makes the 'getGroup()' method available.
Would still be interesting to know of a cleaner way to do this, perhaps without breaking into code. [ September 03, 2008: Message edited by: Rob CB ]
subject: Check for a change in value when iterating