You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by André Faria <an...@mandic.com.br> on 2007/01/24 13:33:27 UTC

Type Conversion Messages i18n

/How can I make the i18n of the message :
/"Invalid field value for field {0}" ?

Regards,
André Faria

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


Re: Type Conversion Messages i18n

Posted by Tom Schneider <sc...@gmail.com>.
I'm assuming this is for Struts 2.  If not, please ignore me. :)

This is one thing I wish they would improve in Struts 2--it's certainly 
not as obvious or trivial as I would expect it, but this little tidbit 
was buried deep in the book: 'Webwork in Action'.  Here is an example of 
one of our messages:

invalid.number.error=Field ${getText(fieldName + '.label')} is invalid, 
please enter a number.

This syntax will not work with the ConversionErrorInterceptor, you must 
manually add a conversion validator to every field where you want a 
conversion error displayed.  This is because the OGNL lookup  on the 
bundle string occurs in the validator framework.  But the idea is that 
the bundle text will go through an OGNL lookup, getText will be called 
on the action and we'll be looking up fieldName + '.label'.  So if the 
fieldName is age, we would lookup age.label in the resource bundle.

This could be made more user friendly if we had a field key in addition 
to the error message key in the xwork validation framework.  This would 
allow the field name lookup to happen automatically and it would be 
available just as fieldName.  (Right now fieldName is only the literal 
text from the XML)
Tom


André Faria wrote:
> /How can I make the i18n of the message :
> /"Invalid field value for field {0}" ?
>
> Regards,
> André Faria
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>


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