Tuesday 21 December 2010

Required field indication with ExtVal - Part 2


The previous time, there was an explanation how you could have some
indication on the input field itself when it is required. As said then, a
custom renderer that changes the appearance of the label which is in front
of the required input field is no longer possible. During the rendering of
the label, the input component has not yet set the required attribute. So
you need another solution if you need that kind of requirement in your

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.

Tuesday 28 September 2010

MyFaces Test framework


I saw a lot of projects where testing could be better and altough a
lot of people won't believe me, good unit testing of your code reduces the
bugs found during functional testing and allows for easier maintenance
later on. But even if the developers are writing a lot of unit tests, some
cases can't be handled properly. Within JSF, you can work a lot with
POJO's which are independent of all other stuff but there are cases where
a kind of integration test could be handy.