File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes validation in struts2 annotation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "validation in struts2 annotation" Watch "validation in struts2 annotation" New topic

validation in struts2 annotation

shekhar john
Ranch Hand

Joined: Feb 02, 2011
Posts: 38
hello ,
i m new to struts2 framework .i m tring to validate my login form with validation annotation,but @validation is depritiated.
i search it so much but all examples are with @validation but it is now depritated so please any body help me to apply validation with annotation.
pooja par
Ranch Hand

Joined: Feb 14, 2011
Posts: 31
@validation is not depriciated

the below link may help you

this may also help you

the 1st 2 points are important from the above link.. you may be missing them.

  • Assure that you're using defaultStack interceptor stack because inside it are workflow and validation interceptors that are responsible of execute validation logic and redirect to appropiate result when validation triggers.
  • Define a result named "input" in action's declaration on struts.xml . This is the result where validation must redirect automatically if exists validation errors. If input result is not defined it will give an error of result not found.

  • shekhar john
    Ranch Hand

    Joined: Feb 02, 2011
    Posts: 38
    thanks a lot pooja .
    Actually my eclipse is showing it @Validation and that's why i was confused .i tried it with your url and it is working.
    thanks once again
    Arne Olaf Godtland

    Joined: Mar 22, 2011
    Posts: 2

    Actually, @Validation is deprecated, if you are annotating the method and not the class. Use the interface @Validations.

    I think this example is excellent:
    Apache Struts 2 Documentation - Validation Annotation

    I also recommend chapter 10 (Exploring the validation framework) in the book Manning - Struts 2 in action, where it is well explained how you create your own custom validators.

    Remember that Struts2 validation is based on XWork framework. So when you are searching for anwers, you may search for XWork as well.
    I agree. Here's the link:
    subject: validation in struts2 annotation
    It's not a secret anymore!