Important Notice - Forums is archived
To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
Form Validation with JSR 303
Hi,
i've some questions about form validation with JSR 303 and pojos within pojos.
I want to build a Form for a complex pojo which contains another pojo
public class MyPojo{
String a;
OtherPojo oPojo;
}
public class OtherPojo{
Date a;
Date b;
}
To build the Form we use a custom FormFieldFactory which returns another FormObject as a Field for Objects of the Type OtherPojo. So i have a Form with a BeanItem<MyPojo> set as the ItemDataSource. this form contains two Fields ( a TextField for the String "a" and a OtherPojoForm for the oPojo Field in MyPojo)
this works fine, but now I want to add a JSR303 validator to the OtherPojo class to ensure that a is befor b.
I'm using the beanvalidationform and the beanvalildationvalidator from the SpringApplication incubator project, which works fine for simple pojos and simlpe forms. But i cannot add a validator directly to a form because the addvalidator method in Form is implemented as "throw new UnsupportedoperationException" and the validator List in AbstractField is private so I can't add a validator to this List.
Does anyone know a way to add a Validator to a Form ?
Or another way to handle Pojos within pojos ?
Could you add a validator directly to the fields created by the OtherPojoForm? You could do this for example by adding a field factory to the form and adding the validators there.
yes i can add validators to these fields, but it wouldn't help. my validator needs access to both fields of the OtherPojoForm as it compares these values.
And I'm trying write a generic solution that works with all kinds of nested pojos/forms and beanvalidation.
the validator is implemented as a JSR303 compliant Validator with an Annotation. this Annotation is placed on the OtherPojo class an not on the OtherPojo Property in MyPojo. this way I can ensure that every use of OtherPojo will be validated through the validator.
Now I just reimplemented Form without the overridden method public void addValidator(Validator validator), so that it's possible to add a validator to a form.
I'm not sure why this method was disabled in the vaadin framework and if the reimplentation will rsult in some sideeffects
Just uploaded a presentation on Vaadin Beam Validator: http://www.youtube.com/watch?v=od61lfvWbn8