• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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>
 
Ranch Hand
Posts: 141
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
reply
    Bookmark Topic Watch Topic
  • New Topic