struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject Translation of fieldName in annotated validations
Date Wed, 25 Sep 2013 05:02:37 GMT
   I have an Action that receives a parameter *email *on a bean *event*. So
basically the parameter is send to the server with name "*<at>*"'. The bean and the parameter are created
correctly, so this part works ok. Now I want to validate the input using
annotations. In order to do that I'm using the following annotation at the
Action level:

        requiredStrings =
            {@RequiredStringValidator(type = ValidatorType.SIMPLE,
                    fieldName = "", key =

and in the I have the following definition
validation-error.mandatory        = The field ${getText(fieldName)} is
mandatory = e-mail

With this setup, if the parameter is empty or not present, the
validator evaluates the expression and returns to the user the following
"The field e-mail is mandatory".

It evaluates the key as an OGNL expression, retrieves the fieldName,
evaluates the getTest, and elaborate the sentence correctly. So it works ok

The issue here is that this forces me to define a property ""
since the attribute fieldName in the annotation is used both to locate the
field that needs validation, and as argument for the getText. Is it
possible to split that those two roles, so I can user my already existing
property "email", instead of having to duplicate it as ""?



  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message