RE: Commons validation framework and struts
The attachment didn't come through. robert -Original Message- From: Abhishek Srivastava [mailto:[EMAIL PROTECTED] Sent: Monday, December 15, 2003 12:31 AM To: 'Struts Users Mailing List' Subject: RE: Commons validation framework and struts Hello Robert, Yes. I have also defined the validator plugin in my struts-config.xml file. I am attaching my example code here. Please tell me why it is not working. Thanks for your help and patience. Regards, Abhishek. -Original Message- From: Robert Taylor [mailto:[EMAIL PROTECTED] Sent: Friday, December 12, 2003 8:21 PM To: Struts Users Mailing List Subject: RE: Commons validation framework and struts Your field names aren't the same. operator1 != operand1 operator2 != operand2 They must be the same or validation on those fields won't occur. robert -Original Message- From: Abhishek Srivastava [mailto:[EMAIL PROTECTED] Sent: Friday, December 12, 2003 9:35 AM To: [EMAIL PROTECTED] Subject: Commons validation framework and struts 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] - 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]
RE: Commons validation framework and struts
Do you have the ValidatorPlugin defined in your struts-config.xml file. For example you should have something like this defined: plug-in className=org.apache.struts.validator.ValidatorPlugIn set-property property=pathnames value=/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml/ /plug-in robert -Original Message- From: Abhishek Srivastava [mailto:[EMAIL PROTECTED] Sent: Sunday, December 14, 2003 1:43 AM To: 'Struts Users Mailing List' Subject: RE: Commons validation framework and struts Hello Robert, Thanks for your reply. It's a typo in my email. My form has fields operand1, operand2 and operator. I have defined the same in the validation.xml still the validation does not occur. Please tell me what am I going wrong. Regards, Abhishek. -Original Message- From: Robert Taylor [mailto:[EMAIL PROTECTED] Sent: Friday, December 12, 2003 8:21 PM To: Struts Users Mailing List Subject: RE: Commons validation framework and struts Your field names aren't the same. operator1 != operand1 operator2 != operand2 They must be the same or validation on those fields won't occur. robert -Original Message- From: Abhishek Srivastava [mailto:[EMAIL PROTECTED] Sent: Friday, December 12, 2003 9:35 AM To: [EMAIL PROTECTED] Subject: Commons validation framework and struts 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] - 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] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Commons validation framework and struts
Hello Robert, Yes. I have also defined the validator plugin in my struts-config.xml file. I am attaching my example code here. Please tell me why it is not working. Thanks for your help and patience. Regards, Abhishek. -Original Message- From: Robert Taylor [mailto:[EMAIL PROTECTED] Sent: Friday, December 12, 2003 8:21 PM To: Struts Users Mailing List Subject: RE: Commons validation framework and struts Your field names aren't the same. operator1 != operand1 operator2 != operand2 They must be the same or validation on those fields won't occur. robert -Original Message- From: Abhishek Srivastava [mailto:[EMAIL PROTECTED] Sent: Friday, December 12, 2003 9:35 AM To: [EMAIL PROTECTED] Subject: Commons validation framework and struts 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] - 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]
RE: Commons validation framework and struts
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]
RE: Commons validation framework and struts
Hello Robert, Thanks for your reply. It's a typo in my email. My form has fields operand1, operand2 and operator. I have defined the same in the validation.xml still the validation does not occur. Please tell me what am I going wrong. Regards, Abhishek. -Original Message- From: Robert Taylor [mailto:[EMAIL PROTECTED] Sent: Friday, December 12, 2003 8:21 PM To: Struts Users Mailing List Subject: RE: Commons validation framework and struts Your field names aren't the same. operator1 != operand1 operator2 != operand2 They must be the same or validation on those fields won't occur. robert -Original Message- From: Abhishek Srivastava [mailto:[EMAIL PROTECTED] Sent: Friday, December 12, 2003 9:35 AM To: [EMAIL PROTECTED] Subject: Commons validation framework and struts 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] - 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]
RE: Commons validation framework and struts
Your field names aren't the same. operator1 != operand1 operator2 != operand2 They must be the same or validation on those fields won't occur. robert -Original Message- From: Abhishek Srivastava [mailto:[EMAIL PROTECTED] Sent: Friday, December 12, 2003 9:35 AM To: [EMAIL PROTECTED] Subject: Commons validation framework and struts 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] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
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]