Dear list,

I've been fighting this problem for some time now, and can't come up
with a solution. Please advice.

In my jsp page I'm iterating an array of Category objects which resides
in the request scope. This is done with the logic:iterate tag like this:

<logic:iterate id="categories" name="category_array">

Each Category-object contains a Message-object field called lastmessage
which in turn contains a timestamp-field (a long).

In session-scope, there is a User object with a lastlogin field (a long).

All objects have the appropriate getters (and setters) for all fields.

Inside the iteration, I'm trying to do a comparison between the
timestamp field of the Message object inside the Category object
currently processed and the lastlogin field of the user object. This is
how I'd like it to work:

<logic:iterate id="categories" name="category_array">
  <logic:present name="user" scope="session">
    <logic:lessThan name="user"
                    property="lastlogin"
                    value="category.lastmessage.timestamp">
       //do something
    </logic:lessThan>
  </logic:present>
</logic:iterate>

Now this doesn't work since the timestamp field is referenced wrongly.
My next thought was to use logic-el taglib, but there's no lessThan tag
in that library, because the jstl-c library is supposed to offer the
same functionality. I tried jstl-c's c:if tag, but the problem is that I
can't reference the iterating categories object, like this:

<c:if test="${user.lastlogin < categories.lastmessage.timestamp}">
  //do something
</c:if>

This doesn't recognize the categories property. So then I'd have to use
the c:iterate tag, but then again I have a bunch of <bean:write/> and
other el-tags inside the iteration as well, using the categories
property created by the logic:iterate tag. These tags wouldn't work
properly if using inside a c:iterate tag (i suppose).

So, what should I do? How can I reference the timestamp-field in the
Message-object inside the Category object in a lessThan tag inside an
iteration? (phew)

Thankful for any advice.

   Fredrik Boström



The relevant code:

<table class="categorytable">
 <logic:iterate id="categories" name="category_array">
   <tr>
     <th>
      <html:link action="/ShowThreads.do"
                 paramId="categoryId"
                 paramName="categories"
                 paramProperty="id">
        <bean:write name="categories"
                    property="name"
                    filter="false" />
      </html:link>
      <logic:present name="user" scope="session">
        <logic:lessThan>  <!-- compare user.lastlogin to      -->
                          <!-- category.lastmessage.timestamp -->
          New messages!
        </logic:lessThan>
      </logic:present>
     </th>
     <th class="categorycontrols">
       <logic:present name="user" scope="session">
         <logic:equal name="user" property="sumode" value="true">
           <html-el:link
action="/EditCategory.do?action=edit&categoryId=${categories.id}">
             Edit
           </html-el:link>
           <html-el:link
action="/EditCategory.do?action=delete&categoryId=${categories.id}">
             Delete
           </html-el:link>
         </logic:equal>
       </logic:present>
     </th>
   </tr>
    <tr>
     <td colspan="2">
      <bean:write name="categories"
                  property="description"
                  filter="false"/>
     </td>
    </tr>
  </logic:iterate>
</table>



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

Reply via email to