If you want to use Struts validation(which you probably do):
struts-config.xml
-------------------
<form-bean name="calcForm" type="org.apache.struts.validator.DynaValidatorForm"
<form-property name="operand1" type="java.lang.String"/>
<form-property name="operand2" type="java.lang.String"/>
</form-bean>
If you are writing your own validation class, you'll want something along these lines:
validation.xml
--------------------
<validator name="requiredArray"
classname="com.paychex.validator.CustomFieldChecks"
method="validateRequiredArray"
methodParams="java.lang.Object,
org.apache.commons.validator.ValidatorAction,
org.apache.commons.validator.Field,
org.apache.struts.action.ActionErrors,
javax.servlet.http.HttpServletRequest"
msg="errors.requiredArray"/>
You could also implement DynaValidatorActionForm if you want to validate per action rather than per form.
hth, Ben
From: "Abhishek Srivastava" <[EMAIL PROTECTED]> Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Subject: Commons validation framework and struts Date: Fri, 12 Dec 2003 20:04:36 +0530
Hello All,
I am trying to learn the new validation framework provided with struts 1.1 and am facing a few problems.
I have a form object which I have derived from ValidatorForm class. In this form I have fields like operator1, operator2. I have created a file called validation.xml where I have made entries like
<form-validation> <formset> <form name='calcForm'> <field name='operand1' depends='required'> </field> <field name='operand2' depends='required'> </field> </form> </formset> </form-validation>
The entry for action in my struts config is
<action path='/calc' type='com.abhi.CalcAction' scope='request' name='calcForm' parameter='action' input='/calc.jsp' validate='true'> <forward name='success2' path='/calc.jsp' /> </action>
<form-bean name="calcForm" type="com.abhi.CalcForm" />
The application is working fine. Except that when I leave the fields operator1 or operator2 empty then no error is reported.
Is there some step which I have missed out? Please help me out.
Regards, Abhishek.
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
_________________________________________________________________
Cell phone ‘switch’ rules are taking effect — find out more here. http://special.msn.com/msnbc/consumeradvocate.armx
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]