You can implement this just as you would in any other programming environment: by saving the previous and the current value in different variables. You can do this using scriptlets, as I see you doing here. You can also do this using the JSTL (for more info, see the Jakarta Taglibs project), which you may find a little easier to work with once you get the hang of it.

Does that answer your question?

Matt

Jones, Marty B. wrote:

Does anyone have any suggestions on how I can compare the previous object's
parameters to determine when my object's category has changed?

-----Original Message-----
From: Jones, Marty B. Sent: Friday, August 15, 2003 7:07 AM
To: [EMAIL PROTECTED]
Subject: Iterate Tag Question



I am using an iterate tag to iterate over a List of items that have a given category. I need to be able to determine when a given category has changed when iterating and push out a header row in a table that I am generating. Is there a way that I can look back a row or save the category from the previous row so that I can compare it with the current row to determine whether or not a category break has occurred. Here is a snippet of my code:


<% String previousCategory = "<empty>"; %>

<table width="100%" border="1" cellspacing="0" cellpadding="3"
frame="hsides">
        <tr>
                <th align="left" nowrap>Filename</th>
                <th align="center">Description</th>
        </tr>
        <logic:iterate id="currElement" name="dbFileBean" property="records"
indexId="index">
                <logic:notEqual name="currElement.categoryName"
value="<%=previousCategory%>">
                        <tr>
                                <td colspan="6"
class="groupBreak"><b><bean:write name="currElement"
property="categoryDesc"/></b><a name="<bean:write name="currElement"
property="categoryName"/>"></a></td>   
                        </tr>
                </logic:notEqual>
                <tr bgcolor="<%=colors[index.intValue()%2]%>">
                        <td align="left" nowrap><img
src="/images/common/spacer.gif" width="15" height="10">
                                <a
href="documentsandfiles?fileId=<bean:write name="currElement"
property="fileId"/>"><bean:write name="currElement"
property="fileName"/></a>
                        </td>
                        <td align="left">
                                <bean:write name="currElement"
property="description"/>
                        </td>
                </tr>
                <% previousCategory =
((DbFileInfo)currElement).getCategoryName();    %>           
        </logic:iterate>
</table>  


The way that I am attempting it from above is not working, the notEqual tag is not seeing that the strings are equal. I would like to be able to get all the scriplets out of the jsp if possible.

Any suggestions would be appreciated.
________________________
Marty B. Jones
Senior Software Engineer
DailyAccess.Com


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to