You should be able to use Spring IoC to inject the messageSource bean
into your validator and grab the message from there.
Matt
On 6/19/07, pat79 <[EMAIL PROTECTED]> wrote:
Hi there,
i have a custom validator for uploading files checking the max size of a
file:
public class ImageUploadValidator implements Validator {
public void validate(Object obj, Errors errors) {
UploadCommand cmd = (UploadCommand) obj;
/* filesize < 5MB */
if (cmd.getMultipartFile().getSize() > 5120) {
Object[] args = new Object[] { "uploadForm.file" ,
"5MB"};
errors.rejectValue("file", "errors.filesize", args, "File
too big.");
}
}
}
I use an error-message from the ApplicationResources_*.properties file:
errors.filesize={0} can not be bigger than {1}.
This is working fine, except that the {0} shouldn't be replaced by plain
text rather by the "uploadForm.file" key, which is also defined in
ApplicationResources_*.properties:
uploadForm.file=File to Upload
Does anybody know how to get along with this?
Thanks for any help.
Patrick
--
View this message in context:
http://www.nabble.com/Validator-and-access-to-*.properties-tf3946375s2369.html#a11194611
Sent from the AppFuse - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
--
http://raibledesigns.com
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]