Struts validate method: I18N error messages

K

Klaus

I have an error message like "{0} is ..." (Resources).

See code below:
The part "key.x.z" is taken from the resource bundle (fine)
The replacment {0} is displayed as it is: "key.x.label" (bad)
=> How can I make the second part being internationlized too?

I work-around the problem by manually getting the bundle by using
PropertyResourceBundle. I do not like it, because when I change the
resource bundle in struts-config.xml the Java code becomes
inconsistent with the config file.

Possible solutions:
Directly access the default bundle from within validate, but how?

Code Example:
=============
public ActionErrors validate(ActionMapping m, HttpServletRequest r) {
ActionErrors errors = new ActionErrors();
if (....)
errors.add("person", new ActionError("key.x.z", "key.x.label"));
return errors;
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,756
Messages
2,569,540
Members
45,025
Latest member
KetoRushACVFitness

Latest Threads

Top