Struts Standard Error Messages
Many people used to Struts will be wondering how to create similar functionality to the standard Struts error messages such as "X is a required field". The problem is that "X" is more than likely to be an internationalised text string as well as the error message body. The following describes how to create "nested" internationalisation lookups within error messages.
Example
Say the following is the contents of the error messages properties file.
error.required={0} is a required field
label.firstname=First Name
This can be resolved within the Spring validation framework as follows.
errors.rejectValue("myfield",
"error.required",
new Object[] {new DefaultMessageSourceResolvable(new String[] {"label.firstname"})},
"First Name is a requred field");
How could this be done for when a property editor rejects a value for being a typeMismatch without writing a custom PropertyEditor?