GWT validation framework, how to specify location of internationalization bundle

901 views Asked by At

This one is related to my previous post. Is it possible in GWT validation framework to specify location of ValidationMessages.properties files and their names? I already have messages translations in my application and I'd prefer them to be in one location.

1

There are 1 answers

0
David Levesque On BEST ANSWER

You could create a custom UserValidationMessagesResolver:

public class CustomValidationMessagesResolver extends AbstractValidationMessageResolver implements UserValidationMessagesResolver {
    protected CustomValidationMessagesResolver() {
        super((ConstantsWithLookup) GWT.create(ValidationConstants.class));
    }
}

In the above code, ValidationConstants is the class resulting from running I18NSync on my properties file.

Then in *.gwt.xml:

<replace-with class="yourpackage.client.validation.CustomValidationMessagesResolver">
    <when-type-is class="com.google.gwt.validation.client.UserValidationMessagesResolver" />
</replace-with>

You can find a complete example here.