Monday, April 13, 2015

Using HTML5 date type with Wicket

Just a quick note to document the following gotcha using HTML5's date input type with Apache Wicket.

In HTML5, you can have an input field that browsers can render with a date picker:

<input type="date" wicket:id="startDate" />

add(new DateTextField("startDate", dateModel, "yyyy-MM-dd"));


The important thing to note is the date pattern "yyyy-MM-dd".  The date is rendered (at least in my locale) as MM/dd/yyyy, but the browser returns the date string as yyyy-MM-dd, and if you don't tell Wicket that, it won't be able to parse the return value as a string, and you'll get an error.

No comments: