struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Fredrik Boström <>
Subject logic:lessThan inside logic:iterate
Date Thu, 16 Jun 2005 17:14:09 GMT
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"
        //do something

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

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">
       <html:link action="/"
         <bean:write name="categories"
                     filter="false" />
       <logic:present name="user" scope="session">
         <logic:lessThan>  <!-- compare user.lastlogin to      -->
                           <!-- category.lastmessage.timestamp -->
           New messages!
      <th class="categorycontrols">
        <logic:present name="user" scope="session">
          <logic:equal name="user" property="sumode" value="true">
      <td colspan="2">
       <bean:write name="categories"

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message