aspose file tools*
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
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: 156
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Struts2---Problem to use s:iterator and s:date to display and pass value