Bean Validation (JSR 303) Demo

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.

Validation Annotations

All annotations defined in the package javax.validation.constraints are supported. For example:

@NotNullmeans that a value is required
@Sizerestricts the length of a string or array or the size of a collection or map
@Maxrestricts the maximum allowed value
@Minrestricts the minimum allowed value
@Patternrestricts a string to a given regular expression
@Digitsrestricts the maximum number of digits of the integer and faction part
@Futurerestricts a date to the dates in the future
@Pastrestricts 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.



Data: BeanValidationDemoData(person=Person [name=, socialSecurityNumber=null, yearOfBirth=null, Licence=null])