<s:iterator value="fruits">
<%
  Calendar cal = Calendar.getInstance();
  cal.setTime(new Date());
  int monthNow = cal.get(Calendar.MONTH);
  cal.setTime(date); //fruit.getDate()
  int monthFruit = cal.get(Calendar.MONTH);
  if(monthNow == monthFruit){ 
  %>
delete delete 
<%}%>
</s:iterator>

If you don't like the script in the page then you can create a public method
on fruit called getExpired.  fruit.getExpired() does the same calendar work
as above based on the internal date value and the current date and returns a
boolen. In that case:

<s:iterator value="fruits">
   <s:if test="expired">
         delete delete 
    </s:if?
</s:iterator>

Depending on how you are doing persistance (JPA on getters/fields/whatever)
you may have to mark this getter as transient....


Milan Milanovic wrote:
> 
> Hi,
> 
> I have a list of Fruit's of type class Fruit { String name; Date date; },
> and I show those fruits using iterator in my .jsp, like this: <s:iterator
> value="fruits"> ... </s:iterator>. Well I need to show some options (e.g.,
> delete fruit) to user if fruit's date is in the current month, how can I
> check this in my .jsp (inside iterator tag) ?
> 
> --
> Thx in advance, Milan Milanovic
> 

-- 
View this message in context: 
http://www.nabble.com/-S2--Checking-current-month-using-struts-2-tags-tp18279808p18298054.html
Sent from the Struts - User mailing list archive at Nabble.com.


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

Reply via email to