This demo explains how the bean validation (JSR 303) could be used.
The fields of a java class (bean) can be annotated with validation information. The validation information will then be considered by Html Dialogs when the field of the class is bound to a widget.
The java class
ch.ivyteam.htmlDialog.demo.input.beanValidation.Person
defines fields annotated with such validation information. The fields of the java class are bound to the
widgets in the form bellow. There
are no validation information given in the *.xhtml file of the Html Dialog itself. However, the Html Dialog
uses the information given on
the annotations of the fields to validate the user input.
All annotations defined in the package javax.validation.constraints are supported. For example:
| @NotNull | means that a value is required |
| @Size | restricts the length of a string or array or the size of a collection or map |
| @Max | restricts the maximum allowed value |
| @Min | restricts the minimum allowed value |
| @Pattern | restricts a string to a given regular expression |
| @Digits | restricts the maximum number of digits of the integer and faction part |
| @Future | restricts a date to the dates in the future |
| @Past | restricts a date to the dates in the past |
There will always be validation requirements, for which these standard annotation won't suffice. For these
cases it is possible to create
your own annotations. See the
@ch.ivyteam.htmldialog.demo.input.beanValidation.LicensePlate
annotation for an example.