I probably should've included the jsp/action code in the original post.
<s2:datetimepicker
name="myDate"
label="myDate.label"
displayFormat="M/d/yyyy"/>
MyAction {
public Date getMyDate() {...}
public void setMyDate(Date value) {...}
...
}
The problem is that the action's date property value isn't preserved. I did
try
<s2:datetimepicker
name="myDate"
value="%{myDate}"
label="myDate.label"
displayFormat="M/d/yyyy"/>
but the same thing happens.
----- Original Message ----
From: Musachy Barroso <[EMAIL PROTECTED]>
To: Struts Users Mailing List <[email protected]>; Jon Wilmoth <[EMAIL
PROTECTED]>
Sent: Tuesday, May 15, 2007 11:56:22 AM
Subject: Re: [s2] datetimepicker - how to preserve original value
This problem is related to this:
https://issues.apache.org/struts/browse/WW-1923
from 2.1 the "value", "startDate" and "endDate" will be evaluated as object, so
we can support Calendar and any object whose toString() returns a parseable
date. In short, use
<s:date value="%{'2007-01-01'}" ../>
instead of
<s:date value="2007-01-01" ../>
so you won't have to make changes for 2.1. To fix your problem now, just using
value="%{foo}" should do, if foo is either a Date object(recommended), or a
string that can be parsed by SimpleFormat.SHORT, SimpleFormat.LONG,
SimpleFormat.FULL, or the format entered in the "displayFormat" attribute
musachy
On 5/15/07, Jon Wilmoth <[EMAIL PROTECTED]> wrote:
I'm using 2.0.7 and am getting errors when the user inputs an invalid date
format. In addition to the stacktrace below, the field's value displayed to
the user becomes "NaN/NaN/0NaN". Is this an oversite in the new tag that
doesn't check to see if a field error exist before attempting to apply
formatting?
May-15-2007 11:43:04:377 AM, PDT [ERROR]
(org.apache.struts2.components.DateTimePicker) - Could not parse date
java.text.ParseException: Unparseable date: "foo"
at java.text.DateFormat.parse (DateFormat.java:337)
at
org.apache.struts2.components.DateTimePicker.format(DateTimePicker.java:309)
at
org.apache.struts2.components.DateTimePicker.evaluateParams(DateTimePicker.java:209)
at org.apache.struts2.components.UIBean.end(UIBean.java:481)
at
org.apache.struts2.views.jsp.ComponentTagSupport.doEndTag(ComponentTagSupport.java:43)
Thanks,
Jon
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
--
"Hey you! Would you help me to carry the stone?" Pink Floyd