This week's giveaway is in the Spring forum.
We're giving away four copies of Learn Spring Security (video course) and have Eugen Paraschiv on-line!
See this thread for details.
Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

validation in struts2 annotation

 
shekhar john
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@validation is not depriciated

the below link may help you

http://www.roseindia.net/struts/struts2/Struts2-annotations.shtml

this may also help you
http://www.javahowto.net/struts2/how-to-validate-through-annotations-struts-2/

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
    Posts: 38
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    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
    Greenhorn
    Posts: 2
    Java Python Spring
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    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.
    XWork
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic