Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Need step by step procedure to use Validation framework

 
Prasad Babu
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic