You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Arun Sharma <ar...@gmail.com> on 2012/01/11 12:07:36 UTC

Struts 2.2.3 annotations based validation

Hi,

I am using *struts 2.2.3* in web application. I want to use struts2
annotations based validations for the form data submitted from UI.

The scenario is:

User fills all the form fields and click on submit button. I have created a
Person class for storing registration form data and RegistrationAction
which triggers the logic for registration. RegistrationAction holds
reference to person object with respected getters/setters.

Please suggest how to validate individual fields of Person class after form
submission, using struts 2 annotations. (Where to write field level
annotations in Action(holding reference to Person DTO) or PersonDTO
carrying form data.)

Do I need to write custom validator by extending the FieldValidatorSupport,
or alternatively the ValidatorSupport class?

-- 
with regards...
arun

Re: Struts 2.2.3 annotations based validation

Posted by Maurizio Cucchiara <mc...@apache.org>.
Hi Arun,
If there are no specific needs, you could start with http://goo.gl/tMYeQand
http://goo.gl/SvRxG
Then if you have some troubles you could ask a more specific question.
WDYT?

Twitter     :http://www.twitter.com/m_cucchiara
G+          :https://plus.google.com/107903711540963855921
Linkedin    :http://www.linkedin.com/in/mauriziocucchiara

Maurizio Cucchiara


On 11 January 2012 12:07, Arun Sharma <ar...@gmail.com> wrote:

> Hi,
>
> I am using *struts 2.2.3* in web application. I want to use struts2
> annotations based validations for the form data submitted from UI.
>
> The scenario is:
>
> User fills all the form fields and click on submit button. I have created a
> Person class for storing registration form data and RegistrationAction
> which triggers the logic for registration. RegistrationAction holds
> reference to person object with respected getters/setters.
>
> Please suggest how to validate individual fields of Person class after form
> submission, using struts 2 annotations. (Where to write field level
> annotations in Action(holding reference to Person DTO) or PersonDTO
> carrying form data.)
>
> Do I need to write custom validator by extending the FieldValidatorSupport,
> or alternatively the ValidatorSupport class?
>
> --
> with regards...
> arun
>