struts-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jose L Martinez-Avial (JIRA)" <j...@apache.org>
Subject [jira] [Created] (WW-4208) Allow customization of validation messages by passing arguments to the validator for the message
Date Wed, 25 Sep 2013 13:52:03 GMT
Jose L Martinez-Avial created WW-4208:
-----------------------------------------

             Summary: 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


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,
                    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

Mime
View raw message