You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Jeroen Simons <je...@gmail.com> on 2008/09/24 15:33:30 UTC

I18n problem with annotation validation

Hi,

I have a i18n problem when validating a field in my action. (Struts  
2.0.11.2)

My validation:
@RequiredStringValidator(
	fieldName = "user.username", key = "error.required", message = "")

My resource bundle reads this:
error.required=${getText(fieldName)} is required.

To have a localised fieldName in my error.required message I have to  
specify a key/value in my resource bundle like this:
user.username=Username.

This will result in an error message called "Username is required."

This is not really convenient. I will then have to specify a lot of  
double entries in my resource bundle (unless I use more than 1  
bundle). I could have another form with a field called username and I  
will need to specify another field called username=Username or  
username=${getText('user.username')}

Is there a solution for passing on args to key="error.required" and  
then use:
error.required={0} is required.

I tried already using the message in @RequiredStringValidator

@RequiredStringValidator(
	fieldName = "user.username", key = "error.required", message =  
"prompt.username")

error.required=${getText(message)} is required.

This does not seem to work.

Thanks!

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org