aspose file tools*
The moose likes Struts and the fly likes Need step by step procedure to use Validation framework Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Need step by step procedure to use Validation framework" Watch "Need step by step procedure to use Validation framework" New topic
Author

Need step by step procedure to use Validation framework

Prasad Babu
Ranch Hand

Joined: Jul 17, 2005
Posts: 57
Hi All,
I am getting manual validation i.e. i am writing the validation code in ActionForm class. But I know this is not a good approach. I would like to use comple Validation frame work for the Form validation either serverside or client side. do anybody explain the step by step procedure to use validation framework(struts). I already searched in the internet for the tutorials but i could not find the right one. I also read a couple of books. but i did not get the result. I am understanding the concept. but i can not implement. I tried so many times to implement but not getting.
If you explain with example application, it would be appreciated. or you please can send any .war application which is implemented with validation to dp4java@yahoo.com
thanks in advance
sureshreddy puli
Greenhorn

Joined: Sep 28, 2005
Posts: 29
Step1: Configure your struts-config.xml as shown bellow.

<plug-in className="org.apache.struts.validator.ValidatorPlugIn">
<set-property property="pathnames"
value="/WEB-INF/validator-rules.xml,/WEB-validation.xml"/>
</plug-in>

Step2: Edit validation.xml as shown bellow.

<form-validation>
<formset>
<form name="XXXXX">
<field property="firstName" depends="required" >
<arg0 key="your key" resourse="false"/>
</field>
</form>
</formset>
</form-validation>

give your form name instead of XXXXX. Eg.loginForm (given in form-bean name)


Step3:Your Form Bean class must extends ValidatorForm class.

------------------------->Server side validations

Step4:You must include the following.

<html:javascript formName="XXXXX" />
<html:form action="..." onsubmit="return validateXXXXX(this)"
------------------------->Javascript validations(Client side)
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Need step by step procedure to use Validation framework