[
https://issues.apache.org/jira/browse/WW-4208?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Lukasz Lenart updated WW-4208:
------------------------------
Fix Version/s: 2.3.17
> Allow customization of validation messages by passing arguments to the
> validator for the message
> ------------------------------------------------------------------------------------------------
>
> Key: WW-4208
> URL: https://issues.apache.org/jira/browse/WW-4208
> Project: Struts 2
> Issue Type: Improvement
> Components: Annotations, XML Validators
> Affects Versions: 2.3.15.2
> Reporter: Jose L Martinez-Avial
> Labels: annotation, validation
> Fix For: 2.3.17
>
>
> As of today the key/messages used by the annotated validators do not allow to
> receive custom arguments, since only the parameters defined by the annotation
> can be used. In order to improve that I suggest to add a parameter keyArgs to
> the validation annotations so it will be passed to the OGNL evaluator when it
> evaluates the key provided in the annotation. That way the following would be
> possible:
> {code}
> @Validations(
> requiredStrings =
> {@RequiredStringValidator(type = ValidatorType.SIMPLE,
> fieldName = "event.email", key =
> "validation-error.mandatory")
> keyArgs={"email","one","two"}
> }
> )
> {code}
> Then the key/message could be something like this:
> {code}
> validation-error.mandatory = The field ${getText(keyArgs[0])} is mandatory
> email= E-mail
> {code}
> And the result would be
> {code}
> The field E-mail is mandatory
> {code}
> It would allow to customize the message even further than it allows now. I
> suppose it would need to be implemented also in xml validations, but I
> haven't used them, so I don't what would be needed for that.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira