Could you guys help me marry GIN and custom bean validator in GWT application (GWT 2.4) ?
GWT compiler gives me following errors:
Rebind result 'javax.validation.ValidatorFactory' must be a class
Rebind result 'com.google.gwt.validation.client.ProviderValidationMessageResolver' must be a class
My GIN module looks like this
@GinModules(ClientGinModule.class)
public interface ClientGinjector extends Ginjector
{
NewOrderView getOrderView();
}
Where NewOrderView
just extends Composite
.
In my .gwt.xml
of my module I have following instructions
<replace-with class="com.mine.courierApp.client.validation.ClientValidatorFactory">
<when-type-is class="javax.validation.ValidatorFactory"/>
</replace-with>
<replace-with class="com.mine.courierApp.client.validation.ClientValidationMessagesResolver">
<when-type-is class="com.google.gwt.validation.client.UserValidationMessagesResolver"/>
</replace-with>
So I thought maybe GIN wants to know this in Java code so I modified my GIN module which became
public class ClientGinModule extends AbstractGinModule
{
protected void configure()
{
bind(javax.validation.ValidatorFactory.class).to(ClientValidatorFactory.class);
bind(com.google.gwt.validation.client.UserValidationMessagesResolver.class).to(ClientValidationMessagesResolver.class);
}
}
But it didn't help although error message became bigger:
Rebind result 'javax.validation.ValidatorFactory' must be a class
Rebind result 'javax.validation.ValidatorFactory' must be a class
Cannot proceed due to previous errors
Rebind result 'com.google.gwt.validation.client.ProviderValidationMessageResolver' must be a class
Update: Detailed GWT compiler output:
[ERROR] Errors in 'jar:file:/C:/work/externals/gwt/gwt-user.jar!/com/google/gwt/validation/client/BaseMessageInterpolator.java'
[ERROR] Line 96: Rebind result 'com.google.gwt.validation.client.ProviderValidationMessageResolver' must be a class
[ERROR] Errors in 'jar:file:/C:/work/externals/gwt/gwt-user.jar!/com/google/gwt/validation/client/GwtValidatorContext.java'
[ERROR] Line 36: Rebind result 'javax.validation.ValidatorFactory' must be a class
[ERROR] Errors in 'jar:file:/C:/work/externals/gwt/gwt-user.jar!/com/google/gwt/validation/client/spi/GwtValidationProvider.java'
[ERROR] Line 39: Rebind result 'javax.validation.ValidatorFactory' must be a class
[ERROR] Cannot proceed due to previous errors
What shall I do ?
It turned out I have to define
<replace-with class="com.mine.courierApp.client.validation.ClientValidatorFactory">
<when-type-is class="javax.validation.ValidatorFactory"/>
</replace-with>
<replace-with class="com.mine.courierApp.client.validation.ClientValidationMessagesResolver">
<when-type-is class="com.google.gwt.validation.client.UserValidationMessagesResolver"/>
</replace-with>
in all gwt modules, even in those that don't use validation at all.