Struts 2.0.11 datetimepicker while using a hyphen as the date separator

Tags:

I had the following bit of code:


<s:datetimepicker key="birthday" label="Birthday" displayFormat="dd-MM-yyyy"/>

I was using validation for the field to make sure that it was between a certain value but every time I submitted it I got an error:


ERROR com.opensymphony.xwork2.interceptor.ParametersInterceptor  - ParametersInterceptor - [setParameters]: Unexpected Exception caught setting 'birthday' on 'class uk.co.prodia.struts2.action.ActionProfile: Error setting expression 'birthday' with value '[Ljava.lang.String;@2029651'

This look like it is related to a bug that is marked as fixed in Struts 2.0.6. I don't know why it happens but the fix is thankfully very simple, simply change the displayFormat not to use hyphens:


<s:datetimepicker key="birthday" label="Birthday" displayFormat="dd/MM/yyyy"/>

At one point I was returned to the page but the field was not the value the I entered, instead it was NaN/NaN/NaN. I haven't been able to reproduce that problem though.

Comments:

Post a Comment:

HTML Syntax: Allowed