Error messages for Struts validation
Posted on 2004-08-05
I've got a question that I don't think is possible, but I want to make sure!
I have a form field that has a maxlength dependent on other options. I have written my own validator to check that the length is valid - ( dependent on these other options) , and that works just fine.
Now to take it one step further, it would be ideal if I could have the error message that I have stored from ApplicationResources.properties be chosen depending on these other options....
So instead of having a generic message: "The length is invalid" or something like that, it could actually say what the length required is. I can't use the actual maxlength validator that does this, because of the way the fields are being used by multiple name codes.
So is there a way to choose a different error message from within the validator class, or is it only possible to have one error message per validator, as entered in the validator-rules.xml?