Hi All
I am new to
struts and need your help in adding a validation to one of my forms. Form name is bookEditForm and it has a value object book. I am trying to add validation for author field in book.
Everything works fine without validations, but I have started getting page not found error after I added the validation.
Changes made:
1) Made bookEditForm to extend BookEditForm instead of ActionForm
2)Added following entry to struts-config.xml
<plug-in className="org.apache.struts.validator.ValidatorPlugIn">
<set-property property="pathnames" value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml"/>
</plug-in>
3) Included validator-rules.xml and following validation.xml in my war.
<form-validation>
<formset>
<form name="bookEditForm">
<field property="author" depends="required,minlength,maxlength">
<arg0 key="bookEditForm.book.author"/>
<arg1 key="${var:maxlength}" name="maxlength" resource="false"/>
<arg1 key="${var:minlength}" name="minlength" resource="false"/>
<var>
<var-name>minlength</var-name>
<var-value>5</var-value>
</var>
<var>
<var-name>maxlength</var-name>
<var-value>11</var-value>
</var>
</field>
</form>
</formset>
</form-validation>
Thanks