jQuery in Action, 2nd edition*
The moose likes Struts and the fly likes Struts2---Problem to use s:iterator and s:date to display and pass value Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts2---Problem to use s:iterator and s:date to display and pass value " Watch "Struts2---Problem to use s:iterator and s:date to display and pass value " New topic
Author

Struts2---Problem to use s:iterator and s:date to display and pass value

walter wang
Ranch Hand

Joined: Jun 02, 2001
Posts: 150
in my Action class has below two variables

Collection<Date> dates;
Date date;

In jsp, how to use s:iterator and s:date to display and pass value for reportdate ? below is my code snippet´╝î see red color marked area

<s:iterator value="dates" status="reportdate">
<tr
class="<s:if test="#reportdate.odd==true">odd</s:if><s:else>even</s:else>">
<s:url id="listmorningurl" action="listmorningReport">
<s:param name="date" value="reportdate" />
</s:url>
<s:url id="listalerturl" action="listalertReport">
<s:param name="date" value="reportdate" />
</s:url>
<td><s:date name="reportdate" format="dd/MM/yyyy"/></td>

<td><s:a href="%{listmorningurl}">
<s:text name="key.morningreport" />
</s:a></td>

<td><s:a href="%{listalerturl}">
<s:text name="key.alertreport" />
</s:a></td>
</tr>
</s:iterator>


public class Walter { public boolean is_Working_Now (boolean is_boss_Coming) { return is_boss_Coming; }
Chris Montgomery
Ranch Hand

Joined: Jan 14, 2004
Posts: 141
I would recommend leveraging JSTL. It's just easier at times...

Here's a date example:
<fmt:formatDate value="${myCollection.myValue}" type="date" dateStyle="short" />

as far as your url parameter goes - assuming you actually have a variable in your collection called 'reportdate' that is accessible to your jsp (public getter/setter) , it should work.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Struts2---Problem to use s:iterator and s:date to display and pass value
 
Similar Threads
Update Database with the newly entered value
passing values from struts2 form to javascript
DisplayTag problem to export Excel not working
DisplayTag Export Question?
Struts2 <s:iterator /> question