Annotation validation setter level

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Annotation validation setter level

José Antonio Delgado Trujillo
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.

Reply | Threaded
Open this post in threaded view
|

Re: Annotation validation setter level

Hedju Hor
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 <[hidden email]> 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: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Annotation validation setter level

José Antonio Delgado Trujillo
Thanks a lot for the link and the explanation.
Un saludo,
José A.

> On 6 Jan 2018, at 10:37, Hedju Hor <[hidden email]> 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 <[hidden email]> 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: [hidden email]
> For additional commands, e-mail: [hidden email]
>