On Wednesday, November 6, 2002, at 08:38 PM, Erik Beeson wrote:
I'm not sure this is a bug after all. The IllegalArgumentException thrown by DateFormatter causes the setValue method call in DateEditor to be bypassed. See this code snippet from DateEditor.http://jira.opensymphony.com/secure/ViewIssue.jspa?key=WW-84If an invalid date text is submitted the attribute will get the current date, while a null value is more appropriate.The problem is in the DateFormatter constructor where the "date" variable is initialized to "new Date()"While I see how this could be an issue, setDate does through an IllegalArgumentException if the date was invalid.
public void setAsText(String txt) {
try {
DateFormatter formatter = new DateFormatter();
try {
formatter.setParser(DateFormat.getDateInstance(DateFormat.SHORT,
ActionContext.getContext().getLocale()));
} catch (Exception e) {
//ignore, use default parser
}
formatter.setDate(txt);
setValue(formatter.getDate());
} catch (Exception e) {
throw new IllegalArgumentException("Unable to set value for " + txt);
}
}
I used a debugger on the BeanUtilTestCase and the setObjDate method did get called on valid dates, but did not get called when an invalid date was submitted.
Please double check my work, but I'm pretty sure there's not really a bug here.
-Maurice
-------------------------------------------------------
This sf.net email is sponsored by: See the NEW Palm Tungsten T handheld. Power & Color in a compact size!
http://ads.sourceforge.net/cgi-bin/redirect.pl?palm0001en
_______________________________________________
Opensymphony-webwork mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork