You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by José Antonio Delgado Trujillo <ja...@gmail.com> on 2018/01/05 18:50:41 UTC

Annotation validation setter level

Annotations validations an alternative way of XML validation or the simplest way to implement the validate method.

Yo have two options:
At method level 
At setter level

In the second if you don’t have the setter in the Action class because it is a property of an object, where do i put the annotation. I think it would be in the model class but it doesn’t work.

I explain better with a example.
Person class have email property and the action class has a field of Person’s type. So the setter method is for Person not for email. If i want to use @EmailValidator in a setter level where does it put the annotation?


Un saludo,
José A.


Re: Annotation validation setter level

Posted by José Antonio Delgado Trujillo <ja...@gmail.com>.
Thanks a lot for the link and the explanation.
Un saludo,
José A.

> On 6 Jan 2018, at 10:37, Hedju Hor <he...@gmail.com> wrote:
> 
> Hi, use  @VisitorFieldValidator
> 1. in Action-Class annotad gettter Method of the model with @VisitorFieldValidator
> 2. @EmailValidator on getter in Model Person.getEmail
> 
> see 
> https://depressedprogrammer.wordpress.com/2007/05/10/struts-2-validation-using-annotations/
> 
> Regards
> Hedju Hor
> 
> On 2018-01-05 19:50, José Antonio Delgado Trujillo <ja...@gmail.com> wrote: 
>> Annotations validations an alternative way of XML validation or the simplest way to implement the validate method.
>> 
>> Yo have two options:
>> At method level 
>> At setter level
>> 
>> In the second if you don’t have the setter in the Action class because it is a property of an object, where do i put the annotation. I think it would be in the model class but it doesn’t work.
>> 
>> I explain better with a example.
>> Person class have email property and the action class has a field of Person’s type. So the setter method is for Person not for email. If i want to use @EmailValidator in a setter level where does it put the annotation?
>> 
>> 
>> Un saludo,
>> José A.
>> 
>> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 


Re: Annotation validation setter level

Posted by Hedju Hor <he...@gmail.com>.
Hi, use  @VisitorFieldValidator
1. in Action-Class annotad gettter Method of the model with @VisitorFieldValidator
2. @EmailValidator on getter in Model Person.getEmail

see 
https://depressedprogrammer.wordpress.com/2007/05/10/struts-2-validation-using-annotations/

Regards
Hedju Hor

On 2018-01-05 19:50, José Antonio Delgado Trujillo <ja...@gmail.com> wrote: 
> Annotations validations an alternative way of XML validation or the simplest way to implement the validate method.
> 
> Yo have two options:
> At method level 
> At setter level
> 
> In the second if you don’t have the setter in the Action class because it is a property of an object, where do i put the annotation. I think it would be in the model class but it doesn’t work.
> 
> I explain better with a example.
> Person class have email property and the action class has a field of Person’s type. So the setter method is for Person not for email. If i want to use @EmailValidator in a setter level where does it put the annotation?
> 
> 
> Un saludo,
> José A.
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org