2013/9/25 JOSE L MARTINEZ-AVIAL <jlm...@gmail.com>: > Hello, > I have an Action that receives a parameter *email *on a bean *event*. So > basically the parameter is send to the server with name "* > event.email=jlmagc<at>gmail.com*"'. 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: > > @Validations( > requiredStrings = > {@RequiredStringValidator(type = ValidatorType.SIMPLE, > fieldName = "event.email", key = > "validation-error.mandatory")} > ) > > > and in the package.properties I have the following definition > validation-error.mandatory = The field ${getText(fieldName)} is > mandatory > event.email = e-mail > > With this setup, if the parameter event.email is empty or not present, the > validator evaluates the expression and returns to the user the following > message: > "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 "event.email" > 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 "event.email"?
I am not sure what you want to achieve? Maybe some example? You can always use a different key i.e. validation.error.email.required and then validation.error.email.required = The field e-mail is required! What you presented is the situation when you want to use exactly the same validator for many fields without specifying key or with the same key - it simplifies but isn't flexible ;-) Regards -- Ćukasz + 48 606 323 122 http://www.lenart.org.pl/ --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org