On Sun, Nov 28, 2010 at 1:26 PM, Martijn Dashorst
<[email protected]> wrote:
> The upcoming standard for HTML 5 defines new input types. These are
> currently only relevant for mobile applications, but new versions of
> firefox, Opera and webkit enabled browsers will provide support for
> these types as well.
>
> Until now HTML provided the following input types:
>  - checkbox
>  - radio
>  - password
>  - text
>  - select
>  - submit
>  - file
>
> HTML 5 supports a couple more:
>  - email
>  - url
>  - number (possibly with spinbox)
>  - range
>  - date, month, week, time, datetime, datetime-local
>  - search
>  - color
>
> Text fields also support new attributes for min, max, step, autofocus,
> placeholder and more. They also support in-browser client side
> validations: min/max/email/url and required. Forms can be told not to
> be validated with novalidate.
>
> Anyway one can write a whole book about HTML 5 (and Mark Pilgrim is
> doing so, http://diveintohtml5.org).
>
> I'd like to discuss how to integrate this new web into wicket. Several
> ways are possible:
>
>  - drop the type="foo" check from textfield and cousins
>  - drop the type="foo" check from textfield and cousins and add markup
> validation based upon HTML validator to our dev utils
>  - expand the type="foo" check to allow more values for text
>  - expand the type="foo" check only in HTML 5 mode (check the page
> markup and detect if it has doctype <!DOCTYPE html>)
>  - expand the type="foo" check only in HTML 5 mode, and validate the
> value with the corresponding field type (i.e. Integer ->
> type="number")
>  - create specialized fields that check for the only correct type,
> i.e. NumberField, EmailField, and include the specialized attributes
> (min, max...)
>
>  - add support for autofocus and placeholder into wicket's textfield
> (regardless of HTML version)
>  - or only for the special HTML 5 fields
>
> Basically there are two ways to look at this: enabling new markup for
> everybody which is compatible with all browsers (input type="number"
> falls back to input type="text"), but will fail strict validation for
> non-html5 markup when used.
>
> In my opinion we should remove the specific checks and rely on markup
> validation based on HTML validator which we should include as a
> devutils package (we should add devutils too in the quickstart).
> Furthermore we should add support for the specific attributes on
> textfield and form for autofocus, placeholder, min, max, pattern, ...
> and mark them as HTML 5 only in the javadoc.

personally i would prefer to have NumberField, UrlField, etc. based on
some html5 detection (doctype or a setting) it can fallback to pre-5
html.

> Now about validation... when doing:
>
>    textfield.setMin(18);
>
> We should add NumberValidator.min(18) to the field as well. If
> possible I would do it the other way round too:
>
>    textfield.add(NumberValidator.min(18)); // adds the min attribute
> to the tag...

i prefer the latter. i have already done some work to enable this by
making IValidator a mixin for behaviors, this way validators can add
attributes to tags. when 1.5 is out and we start on 1.6 i will commit
this change.

-igor

> This would also work for PatternValidator. In order to keep folks
> working on HTML 4.01 or XHTML 1.0/1.1 happy, we should make this
> conditional on the markup settings (supportsHtml5TagsAndAttributes()).
>
> Martijn
>

Reply via email to