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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to