Hello Ben, I am not using Dynamic forms. I have defined my own form object which derives from ValidatorForm. Are you saying that I must switch to dynamic forms if I want to use the validator framework? Or define my own validtors?
One thing which I couldn't find in the validation framework was how to do validation only for a specific value. In my example I have operand1, operand2 and operator. If the operand2 is 0 and the operator is "/", then I would like to check this and raise an error "division by 0 not allowed" for other operators 0 is allowed for operand2. Actually with this prototype I was trying to find out how useful the validation framework is. Also, last time when I worked on struts the validation logic was put inside the form class itself. Is that still allowed? I also have some concerns regarding the use of the XML based validation framework. For my application, validation can get very complex. If I try to do everything via XML then the XML will get bloated and perhaps more complex than the java code. I would need advise from people who have used this framework for complex data validation to confirm whether it can easily be achieved and whether the xml code is easily understandable. Regards, Abhishek. -----Original Message----- From: Ben Anderson [mailto:[EMAIL PROTECTED] Sent: Friday, December 12, 2003 8:21 PM To: [EMAIL PROTECTED] Subject: RE: Commons validation framework and struts You need to decide if you want to use Struts validation or define your own class. You're example below is inconsistent: 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] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]