Any help/takers ? -----Original Message----- From: Janarthan Sathiamurthy Sent: Thursday, March 25, 2004 10:16 PM To: [EMAIL PROTECTED] Subject: Struts Validator and Select boxes
Hi, I am using Struts validator. One page of mine has dates displayed as "MM" "DD" "YYYY". All the above 3 are displayed in seprate combo/select boxes. I need to do some custom validations on these fields. I wrote a custom class for the same Looks like - public static boolean validateDates(Object bean, ValidatorAction validatorAction, Field field, ActionErrors errors, HttpServletRequest request) { String actionType = ValidatorUtil.getValueAsString(bean, field.getVarValue("actionType")); // A hidden form field String fromMonth = ValidatorUtil.getValueAsString(bean, field.getProperty()); String fromDay = ValidatorUtil.getValueAsString(bean, field.getVarValue("fromDay")); String fromYear = ValidatorUtil.getValueAsString(bean, field.getVarValue("fromYear")); String toMonth = ValidatorUtil.getValueAsString(bean, field.getVarValue("toMonth")); String toDay = ValidatorUtil.getValueAsString(bean, field.getVarValue("toDay")); String toYear = ValidatorUtil.getValueAsString(bean, field.getVarValue("toYear")); System.out.println("actionType " + actionType); System.out.println("fromMonth " + fromMonth); System.out.println("fromDay " + fromDay); System.out.println("fromYear " + fromYear); System.out.println("toMonth " + toMonth); System.out.println("toDay " + toDay); System.out.println("toYear " + toYear); return true; } O/P of the above code - actionType searchPage fromMonth 2 fromDay null fromYear null toMonth null toDay null toYear null It also gives me "No Name Specified error". Point to note is that the all other fields other than 'actionType' are select boxes. It gives a null for all the field types that are of html:select. Is this a known BUG or am i going wrong somewhere ? Error LOG - Mar 25, 2004 9:53:11 PM org.apache.commons.validator.ValidatorUtil getValueAsString SEVERE: No name specified java.lang.IllegalArgumentException: No name specified at org.apache.commons.beanutils.PropertyUtils.getNestedProperty(PropertyUtils.java:721) at org.apache.commons.beanutils.PropertyUtils.getProperty(PropertyUtils.java:801) at org.apache.commons.validator.ValidatorUtil.getValueAsString(ValidatorUtil.java:121) at com.mot.servicetools.util.OCSReportsDateValidator.validateDates(OCSReportsDateValidator.j ava:55) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at org.apache.commons.validator.Validator.validateFieldForRule(Validator.java:454) at org.apache.commons.validator.Validator.validateField(Validator.java:544) at org.apache.commons.validator.Validator.validate(Validator.java:582) at org.apache.struts.validator.DynaValidatorActionForm.validate(DynaValidatorActionForm.java :125) at org.apache.struts.action.RequestProcessor.processValidate(RequestProcessor.java:942) at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:255) at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482) at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525) at javax.servlet.http.HttpServlet.service(HttpServlet.java:760) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.jav a:1053) at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:387) at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:305) at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletC ontext.java:6310) at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:317) at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:118) at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:36 22) at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2569) at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:197) at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:170) Thanks & Regards, Janarthan S. --------------------------------------------------------------------- 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]