Apache MyFaces Extensions Validator introduced

In a typical Java EE web application, there’s almost always the problem of where to put the validation. Of course there’s only one place where validation belongs: in the model. So if you’re e.g. using EJB as persistence layer, the EJB Entities is where the validation code belongs. However, from a usability point of view, one never wants to leave all validation out of the UI code. This often leads to duplicate validation code. While not ideal, duplicate validation code is often considered as inevitable.

Yesterday I stumled upon Apache MyFaces Extensions Validator (a.k.a. ExtVal, formerly sev-en), a JSF based solution that looks very promising. I did not have a chance to try it myself yet, but it promises some nice things:

  • Annotation based validation. Annotations can be placed anywhere in the Java code: in backing beans as well as in EJB entities:
  • Reuse of EJB annotations. If you for example use a @Column(nullable=false) annotation, ExtVal will know the field is required and there will be no need to add an required validation manually.
  • ExtVal is extensible, allowing you to define your own annotations or reuse other annotations.
  • Even client side validation is covered. (Be it somewhat limited at the moment…)

ExtVal cannot be called mature yet, but it certainly looks promising! I’ll give it a try as soon as I get the chance! Please leave a comment if you have some experience with ExtVal already.

Further information:

 

Leave a Comment

Comments are closed.