struts-user mailing list archives

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

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("", new String[] { "First Name"}));

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

View this message in context:
Sent from the Struts - User mailing list archive at

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message