Question

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.

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top