struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cm132005 <cm132...@gmail.com>
Subject Struts 2 - Parameterized error messages
Date Mon, 04 May 2009 19:27:07 GMT

Hi,
 
We are migrating our Struts 1.x application to Struts 2.1.6 and currently we
are using Struts Validation framework where the parameterized error messages
are picked up from the resource bundle.

field.required=Field '{0}' is required.
field.numeric=Field '{0}' must be a number.

Expected output:
Field 'First Name' is required.
Field 'Last Name' is required.
Field 'Age' must be a number.
Field 'Cost' must be a number.

The parameter is not always an input value but a label or a String being
passed. It is working fine in Struts 1.x using ActionMessage:

errors.add("fName", new ActionMessage("field.required", "First Name"));

But not working in Struts 2 using getText():
//String getText(String key, List args);
//String getText(String key, String[] args);
addActionError(getText("field.name", new String[] { "First Name"}));

Any help on how to achieve this in Struts 2 would be greatly appreciated.

Thanks.
-- 
View this message in context: http://www.nabble.com/Struts-2---Parameterized-error-messages-tp23374965p23374965.html
Sent from the Struts - User mailing list archive at Nabble.com.


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


Mime
View raw message