Friday, October 23, 2009

[add-on] customizable severity feature and the continue with warnings add-on

the next version of extval will offer violation severities for constraints via extval-validation parameters as well as via jsr303 payload parameters. that means it's possible to define the severity for every constraint.

sometimes it is needed that you can save the form-data and continue in the application even though there are still warnings. so version x.x.3 (for jsf 1.x and jsf 2.x) of extval will allow that you can change the behavior (depending on the severity) via a custom add-on.

that means:
the user tries to submit invalid data. there are just warnings and no errors. so the page gets refreshed and the warnings are displayed. so far we have the expected jsf behavior. if the user clicks again on the (same) button the add-on recognizes that the user already saw the warnings and if there are no errors the warnings are ignored this time. the usage is quite simple:

the required steps:

add extval to the project
add the add-on to the project

use the constraints
from extval:

or from jsr 303

and within the form you just have to add the following hidden field:

that's it!

if you would like to have a button which is still strict and doesn't continue with warnings, you can use a special parameter. since the implementation of the add-on is quite simple it's also possible do implement it the other way round.

optional for the strict behavior:

the add-on is available at: and requires the current trunk version of extval (or the next milestone v.1.2.3M2)

Monday, October 12, 2009

[preview] client-side validation with jsr 303

after updating to the newest ri-version of bean-validation (jsr 303) i added some new functionality to the bean-validation (integration) module of myfaces-extval. the "new" functionality is already known from previous releases of the property-validation module. currently it works with jsf 1.x., however, there is also a branch for jsf 2.0 which will be updated before the next release.

so i started to refactor the featureset-01 example (which is already shipped with myfaces-extval) to bv-constraints. since myfaces-extval provides ui-optimized approaches not everything will be possible. anyway, the result of this first step is client-side validation of @NotNull and @Size via the client-side validation feature of myfaces trinidad.

the rendered result:

as you might already know extval also initializes the component based on constraints. that results in the correct values e.g. of the maxlength attribute - a section of the page above:

this example uses the same xhtml pages like featureset-01 - so the important part of the facelets-component is:

and the most important part - a section of the entity: