Intro

The Intro page provides an overview and describes the motivation for the features described below. This page explains the most important APIs and mechanisms of the bean validation module provided by ExtVal. Please note that this page doesn't show all possibilities (and it's also no tutorial for JSR 303). If you have any question, please contact the community!

Dependencies

The page ExtVal Modules provides an overview about ExtVal modules and how to add them to your project.

For using the features described in this page, you have to add the core and the bean validation module for the JSF version you are using.

Setup

As usual it's quite easy to use BV with MyFaces ExtVal.
Use the Validation-Module for BV (myfaces-extval-bean-validation-x.x.3+ e.g.: myfaces-extval-bean-validation-1.2.3.jar) instead or in addition to the property-validation module of ExtVal. BV is a different story, however, you can use both validation modules in parallel. Also the component support modules (or the optional generic support module to enable e.g. RichFaces support) are completely compatible and can be used as usual.

Besides the core of ExtVal and the BV integration module, you just have to add BV itself (e.g. Hibernate Validator v4). After adding the required jar libs to the project you can start using BV constraints immediately without additional configuration.

So basically that's it!

Available Examples

Besides the examples which are shipped with ExtVal r3+ itself there are some examples out there.
E.g. there is a sample application which shows JSF 1.2 + PrimeFaces + MyFaces ExtVal in action.

Also os890/bv will provide some additional examples.

Advanced Features

Compared to the standard integration of BV in JSF 2.0+ MyFaces ExtVal offers additional features.

For example

  • Typesafe group validation via annotations (instead of the tag f:validateBean)
  • Severity aware validation (+ nonblocking warn mode)
  • Model validation
  • Component initialization
  • Trinidad based client-side validation
  • Dependency injection
  • Integration in JSF 1.x (and 2.x)
  • Mapped constraint source (ExtVal r4+)
  • ...

More details are available here.

Spring 3 support

As alternative there is an add-on for Spring 3 and the BV integration (= ExtVal validation module) to allow typesafe dependency injection in constraint validators.

Mapped Constraint Source

The concept is similar to @JoinValidation (provided by the property-validation module. However, this version is more type-save and it is supported by the property- as well as the bean-validation module.

Since both modules support the same syntax you will find further information here.

Extended Support of @Valid

The std. integration of BV in JSF 2.0 doesn't allow to continue the validation within CustomType. So ExtVal offers an additional feature which allows using @javax.validation.Valid for custom types.

Advanced @Valid example
public class CustomType
{
    @NotNull
    private String property1;

    @Size(min = 3)
    private String property2;

    //+ getter-/setter-methods
}

public class CustomBean
{
    @NotNull
    @Valid
    private CustomType property;

    //+ getter-/setter-methods
}

If you are providing a custom converter, you can access the property via customBean.property and all constraints (including the constraints within CustomType) will be validated.

  • No labels