Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
walter wang
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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>
 
Chris Montgomery
Ranch Hand
Posts: 141
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic