I\'m developing a GWT application with a Spring backend that uses JSR 303 validation. The application can go offline and use the browser HTML5/Gears database instead.
<
GWT 2.5 has a new feature just for this : https://developers.google.com/web-toolkit/doc/latest/DevGuideValidation
It uses the Hibernate Validator.
1) You will need to extend AbstractGwtValidatorFactory and apply your bean e.g. :
public final class SampleValidatorFactory extends AbstractGwtValidatorFactory {
/**
* Validator marker for the Validation Sample project. Only the classes and groups listed
* in the {@link GwtValidation} annotation can be validated.
*/
@GwtValidation(Person.class)
public interface GwtValidator extends Validator {
}
@Override
public AbstractGwtValidator createValidator() {
return GWT.create(GwtValidator.class);
}
}
2) Then add this to your gwt.xml :
3) Validate your bean
Validator validator = Validation.buildDefaultValidatorFactory().getValidator();
Set> violations = validator.validate(person);