Details
-
Improvement
-
Status: Open
-
Minor
-
Resolution: Unresolved
-
None
-
None
-
struts 2.1.8.1 with xwork-core 2.1.6
Description
You can override default type conversion error message defining the key xwork.default.invalid.fieldvalue into your Resource Bundle property-file, for example: xwork.default.invalid.fieldvalue=Invalid field value for field "
{0}".or defining the key invalid.fieldvalue.<propertyName> for the specific field, for example: invalid.fieldvalue.property.name = Invalid field value for field "Property Name".
This is managed by com.opensymphony.xwork2.conversion.impl.XWorkConverter.java:
public static String getConversionErrorMessage(String propertyName, ValueStack stack) {
String defaultMessage = LocalizedTextUtil.findDefaultText(XWorkMessages.DEFAULT_INVALID_FIELDVALUE,
ActionContext.getContext().getLocale(),
new Object[]{ propertyName });
List<String> indexValues = getIndexValues(propertyName);
propertyName = removeAllIndexesInProperyName(propertyName);
String getTextExpression = "getText('" + CONVERSION_ERROR_PROPERTY_PREFIX + propertyName + "','" + defaultMessage + "')";
String message = (String) stack.findValue(getTextExpression);
if (message == null) { message = defaultMessage; } else { message = MessageFormat.format(message, indexValues.toArray()); }
return message;
}
The parameter {0}
(propertyName) is the only one parameter passed to LocalizedTextUtil.findDefaultText(...).
It would be very useful to have a second parameter
with the localized label of the field (if present).