开发者

All days in struts2 datetimepicker are replaced by NaN when invalid date is submited

开发者 https://www.devze.com 2023-01-29 22:25 出处:网络
I\'m using the tag datetimepicker in my struts22.0.11 app with the folowing tag: <s:datetimepicker name=\"data\" displayFormat=\"dd/MM/yyyy\"/>

I'm using the tag datetimepicker in my struts2 2.0.11 app with the folowing tag:

<s:datetimepicker name="data" displayFormat="dd/MM/yyyy"/>

In my action there is a field of the type util.开发者_C百科Date named data with the correct getter and setter. If the user uses the calendar to pick the day, it works fine, but if one "accidently" writes an invalid date it throws a parse exception (as expected) and when the form reapears the datetimepicker has the days replaced by NaN and the calender becomes unusable.

Interesting, I wasn't able to find anything in Google about this simple error.

Thanks in advance, Saul


I finally found an answer for my question:

<s:datetimepicker name="remocao.criacao" value="" displayFormat="MM/dd/yyyy"/>

That's all! =) I just needed to put the attribute value with no value and it worked! It gives now the exception java.text.ParseException: Unparseable date: "", but it does no harm.

Thanks again, Saul

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号