Search code examples
javagwterrai

Making GWT Validation work


I have a working Errai GWT app (GWT version: 2.5.1, Errai version: 3.0.0.Final), merely adding the Errai Validation in the gwt.xml (after adding its dependencies in the POM):

  <inherits name="org.hibernate.validator.HibernateValidator" />
  <inherits name="org.jboss.errai.validation.Validation" />

Throws this error:

Compile with -strict or with -logLevel set to TRACE or DEBUG to see all errors.
   [ERROR] Errors in '/tmp/gwt-codeserver-2599039351007089711.tmp/com.myapp.App/compile-1/gen/org/jboss/errai/validation/client/ValidatorFactoryImpl.java'
      [ERROR] Line 9: The value for annotation attribute GwtValidation.groups must be an array initializer
      [ERROR] Line 9: The value for annotation attribute GwtValidation.value must be an array initializer
      See snapshot: /tmp/org.jboss.errai.validation.client.ValidatorFactoryImpl2638227711022430113.java
   [ERROR] Errors in 'com/google/gwt/validation/client/spi/GwtValidationProvider.java'
      [ERROR] Line 38: Rebind result 'org.jboss.errai.validation.client.ValidatorFactoryImpl' could not be found
[ERROR] Compiler returned false

Solution

  • I think you have mixed "native" GWT validation and Errai validation, and GWT validation works only with hibernate-validator-4.1.0.

    With Errai you don't have to create your own ValidationFactory, just @Inject a Validator.