Monday, January 28, 2013

Validation - localizing field names in annotations

We are using the new GWT validation library in 2.5.

We are adding an aggregated list of violations to our screen. This list must display the localized field name.

@MyNotNull(foo= "Stage")  public String getStage();  

Localized message needs to display

"Stage is a required field"

The message in MyValidationMessages.properties reads

{foo} is a required field

Note that annotations do not allow non-constant values to be assigned to attributes. So we have to get the locale value somehow at design time :/

This will not work

@MyNotNull(foo = injector.getLocale().errorMessage())   public String errorMessage()  

How do I use localeKey to look up the locale in the locale files since the property requires a constant?

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

No comments:

Post a Comment