Monday, 29 November 2010

Myfaces Extensions Validator release 4

With the latest release of the ExtVal framework, release 4, there are a few new major features and a lot of small improvements. And if you are using JSF 2.0, you definitely should upgrade to this version due to his improved integration.
Here is a list of the main features :

  1. Mapped constraint source

    It allows you to, for example, specify that the DTO classes must use the same validations as defined on the entity object. Without the need to copy those validations (DRY - Don't repeat yourself, see also here)
  2. Type safe configuration through Java API

    Until now, the configuration of the framework, if you needed to change something, could be done by specifying configuration parameters within web.xml. Now, it is also possible to specify them in Java through the StartupListener mechanism in a type-safe way. No longer typo errors.
  3. Improved integration with various frameworks

    There is now support for the @Valid annotation of bean validation, Integration with CDI (by using CODI, here) and the scripting framework (JSR 223)
  4. Performance

    There is also some major performance improvements achieved, so the overhead becomes of ExtVal becomes minimal.
  5. New and improved annotations

    There is a new @EmptyIf annotation, the reverse of the already existing @RequiredIf, and some improvement to the already existing ones like a case insensitive comparison.
  6. New add-ons

    There are 2 new major add-ons available that offer some nice functionality. It is the multi field Bean Validation and the required label add-on.
  7. There is also some effort done in better project documentation through the javadocs and a new wiki area.
See for a more complete overview

Thursday, 4 November 2010

Required field indication with ExtVal - Part 1

By using the MyFaces extension Validation framework, ExtVal called in short, we are able to create powerful validation rules that can be used in JSF. Validation rules are no longer encoded in the view layer, the JSP or the XHTML files, but defined by placing annotations on the model and backing bean classes. And that is also where they belong, since validation is linked to the data and not the representation we happen to have or like.

But with ExtVal, we can no longer use the custom renderers we have to indicate that a field is required. Without ExtVal, is was common to have a custom renderer that looked at the required property of the field and allowed us to have some indication that the field is required. That could be a style class that changes the appearance (a yellow background on the field) or some character like an asterisk by the label that goes with the field. Such custom renderers no longer work by default, since the
components in the tree have no longer indications of the validations that are needed.