wood burning stoves 2.0*
The moose likes Struts and the fly likes validation problem in struts Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "validation problem in struts " Watch "validation problem in struts " New topic
Author

validation problem in struts

shankhas sanyal
Ranch Hand

Joined: Jun 15, 2008
Posts: 45
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


I love this place!
udaykumar maddigatla
Ranch Hand

Joined: Feb 03, 2009
Posts: 69
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




SCJP 5.0(84%), SCWCD 5.0(97%), SCDJWS 5.0(98%)
shankha sanyal
Greenhorn

Joined: Sep 12, 2007
Posts: 6
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!!!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: validation problem in struts
 
Similar Threads
Problem with Struts validator
Struts Error Help Needed
Problem while creating Struts application
Problem in inserting values to database from action class
Could not get the connection in struts database application