How to use the html5 calendar input type at the gate

I am experimenting with HTML5. I would like to know how Wicket works with HTML5 input types such as date and email address, if at all? Wicket is currently using a java script to generate a calendar for entering dates.

What complicates this problem is how Wicket handles a browser that does not support HTML5 input tags of type date (and other new HTML5 tags).

+4
source share
2 answers

Wicket (1.5 onwards) does not support input type = 'date' or similar constructions out of the box. There's a DateTextField in Wicket Extensions, but it doesn't specify type='date' (yet). I would suggest creating your own implementations that correctly set the type attribute (my assumption why they were not added to the field is that it will break existing applications).

Here EmailTextField , NumberTextField and others . They add the type attribute and validate data entry on the server.

Browsers that do not support HTML5 inputs return to type='text' , so there is nothing else for the Wicket point. The gate will still validate input in accordance with established rules.

+4
source

You just need to override the TextField # getInputType () method and return " date " so that you skip the onComponentTag method from the TextField component. For example, if you do not want to create your own component, you can use an anonymous class as follows:

  DateTextField dob = new DateTextField("dob", dobModel){ private static final long serialVersionUID = 1L; /* (non-Javadoc) * @see org.apache.wicket.markup.html.form.TextField#getInputType() */ @Override protected String getInputType() { return "date"; } }; 
0
source

All Articles