File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

validation problem in struts

 
shankhas sanyal
Ranch Hand
Posts: 45
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all
i am new to struts and i am facing a problem. i hope to find a solution from all you guys ...
i have a simple user name and password login screen that checks the entered information from a mysql database. without validation framework this works. when i added the validation framework, supposed to show "name is required."

in my Actionbean i have added a validate(); when i comment this. i cannot login. but i can validate. when i uncomment this i can login but cant validate.

here are:

1. struts-config.xml
2. validator.xml
3. DBStrutsAction.java (action class)
4.DBStrutsLoginValidatorBean.java (my actionbean)
5. index.jsp (input file)
6. ApplicationResources.properties

thanks
please help me!!!
Shankha

struts-config.xml


validator.xml




DBStrutsAction.java (action class)



DBStrutsLoginValidatorBean.java (my actionbean)




index.jsp



ApplicationResources.properties
 
udaykumar maddigatla
Ranch Hand
Posts: 69
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

You are extending ValidatorForm, that means, no need to write validate() method. Validation will be done from validation.xml file.

whatever the validations you want to write... you have to specify in the validation.xml. That is the main funda of extending the ValidatorForm.

If you still want to use both validation.xml as well as validate() method. You have to write the below line of code



instead of



Try to change the code as shown above. it will work



 
shankha sanyal
Greenhorn
Posts: 6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
udaykumar maddigatla wrote:Hi

You are extending ValidatorForm, that means, no need to write validate() method. Validation will be done from validation.xml file.

whatever the validations you want to write... you have to specify in the validation.xml. That is the main funda of extending the ValidatorForm.

If you still want to use both validation.xml as well as validate() method. You have to write the below line of code



instead of



Try to change the code as shown above. it will work








thank you very much it works now!!
Your the best ever!!!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic