Posting whats in your validation.xml for the form and the bit of your jsp
with your select fields would be helpfull.

If you take the "fromDay" as an example, you are using
field.getVarValue("fromDay")  - if you don't have a "var" defined in your
validation.xml for "fromDay" then that would cause the "No Name Specified"
error - same goes for "fromYear", "toMonth", "toDay" and "toYear".

As for getting nulls, looks to me again that whats specified for the "vars"
in your validation.xml doesn't tie up with the names specified on your form.

>From your code I would expect something like the following in your
validation.xml

<form.....>
    <field ....>
        <var><var-name>fromDay</var-name>
                  <var-value>formFromDay</var-value>
        </var>
        <var><var-name>fromYear</var-name>
                  <var-value>formFromYear</var-value>
        </var>
        <var><var-name>toMonth</var-name>
                  <var-value>formToMonth</var-value>
        </var>
        <var><var-name>toDay</var-name>
                  <var-value>formToDay</var-value>
        </var>
        <var><var-name>toYear</var-name>
                  <var-value>formToYear</var-value>
        </var>
    </field>
</form>

Do you have the properties in your form correct (i.e in this example
formFromDay, formFromYear, formToMonth, formToDay, formToYear).

Niall


----- Original Message ----- 
From: "Janarthan Sathiamurthy" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, March 25, 2004 4:46 PM
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.j
ava:721)
        at
org.apache.commons.beanutils.PropertyUtils.getProperty(PropertyUtils.java:80
1)
        at
org.apache.commons.validator.ValidatorUtil.getValueAsString(ValidatorUtil.ja
va:121)
        at
com.mot.servicetools.util.OCSReportsDateValidator.validateDates(OCSReportsDa
teValidator.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:4
54)
        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(DynaValidatorAc
tionForm.java
:125)
        at
org.apache.struts.action.RequestProcessor.processValidate(RequestProcessor.j
ava: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(Servle
tStubImpl.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(W
ebAppServletC
ontext.java:6310)
        at
weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubjec
t.java:317)
        at
weblogic.security.service.SecurityManager.runAs(SecurityManager.java:118)
        at
weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletCo
ntext.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]

Reply via email to