People following our work and vision on Bean Validation know that the ultimate goal is to get the ecosystem of Java frameworks to natively integrate Bean Validation where it makes sense. A particularly important area is the the presentation layer that should call Bean Validation to validate the values to be put in the domain model.

This is a feature we have added in JSF 2 and I am happy to see the model being embraced by other frameworks. A new addition to the game is Wicket: Zenika has created a project to integrate Bean Validation in Wicket just like we did for JSF. It's all explained here.

If I may, my next wish is to get rid of this annoying lonely line:

personForm.add(new JSR303FormValidator());

Just get it to work out of the box :) Aside from this detail, this is exactly how a component based framework should integrate Bean Validation. great work.

26. Feb 2010, 01:10 CET | Link

In my opinion, what is actually missing to get a more pervasive use of Bean Validation is parameter validation. At the moment we can't make use of Bean Validation API for example in this scenario (am I wrong?):

public void action(@Param @NotNull String id) {

It would be nice a step forward for example for JSR311, and maybe for Seam/Weld extensions(?).

26. Feb 2010, 06:55 CET | Link
Paul Mooney | paul.mooney(AT)

This is definitely cleaner than the way I was doing it with Seam 2 (look at Seam 2 Wicket example with all of its PropertyModels instead of just the nice CompoundProperty model.)

As for eliminating that one liner, just extend the Form class, and add the JSR303 validator in the constructor (?).

26. Feb 2010, 10:45 CET | Link

Tapestry 5.2, not released yet, has an integration with JSR 303 too: Just add the annotations to the fields or properties and it works. :)

26. Feb 2010, 14:43 CET | Link
Thiago wrote on Feb 26, 2010 04:45:
Tapestry 5.2, not released yet, has an integration with JSR 303 too: Just add the annotations to the fields or properties and it works. :)

Cool :)

26. Feb 2010, 14:47 CET | Link

The more pervasive use of annotations could not be standardized in Bean Validation per se. But it was intended in the design that parameters and method results could be validated assuming an interception framework could delegate this work to Bean Validation (it's in one of the appendixes). This should definitely be a Weld extension. Spring 3 has something similar too for their JAX-RS-like entry points.

26. Feb 2010, 15:07 CET | Link

Emmanuel, maybe It would be enough an API like

validation.validate(String.class, NotNull.class, value);

to be called by other frameworks, instead of a complete implementation in BeanValidation.

26. Feb 2010, 17:37 CET | Link
Olivier Bourgeois

Here is another implementation of JSR-303 integration in Wicket shown in this blog entry :

Wicket 1.4 and JSR-303

It adds Ajax feedback to the form.

26. Feb 2010, 23:53 CET | Link
I haven't been following things closely (haven't been active on/ with Wicket for a while), but it should be possible for validation frameworks for Wicket to written in such a way that you don't have to manually add validators to forms and form fields.

One project I worked on did that like this:

addComponentOnBeforeRenderListener(new ValidationListener());

in your override of WebApplication, and ValidationListener would look like:

public final class ValidationListener implements IComponentOnBeforeRenderListener {
  public void onBeforeRender(Component component) {
    if (component instanceof FormComponent && !component.hasBeenRendered()) {
      processComponent((FormComponent) component);

  public void processComponent(FormComponent component) {
    IModel model = component.getModel();
    if (model instanceof IPropertyReflectionAwareModel) {
      Field field = ((IPropertyReflectionAwareModel) model).getPropertyField();
      if (field != null) {
        processComponentField(field, component);

Where processComponentField searches for Hibernate annotations etc to determine the kind of checks that need to be done, and if it finds any, it just adds the validators to the form field.

FWIW, I don't think having the ability to do personForm.add(new JSR303FormValidator()); is bad in any way. It makes code very explicit. But for those who are OK with a bit more magic, IComponentOnBeforeRenderListener is a way to achieve that.