You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Janarthan Sathiamurthy <ja...@mphasis.com> on 2004/03/27 06:57:33 UTC

RE: Struts Validator and Select boxes

Hi Niall,

I am attaching the validation.xml and the jsp that i have used.
I have done the exact thing that you had specified earlier before posting
to the mailing list.
I am not clear where i am going wrong.

The Struts-config entry goes like - 
		<form-bean name="ocsReportForm" type="org.apache.struts.validator.DynaValidatorActionForm">
			<form-property name="monthFrom" type="java.lang.String" />
			<form-property name="dayFrom" type="java.lang.String" />
			<form-property name="yearFrom" type="java.lang.String" />
			<form-property name="monthTo" type="java.lang.String" />
			<form-property name="dayTo" type="java.lang.String" />
			<form-property name="yearTo" type="java.lang.String" />
			<form-property name="actionType" type="java.lang.String" />
			<form-property name="pageNumber" type="java.lang.String" />
			<form-property name="numberOfRows" type="java.lang.String" />
			<form-property name="dateFrom" type="java.lang.String" />
			<form-property name="dateTo" type="java.lang.String" />
		</form-bean>

Regards,
Janarthan S

-----Original Message-----
From: Niall Pemberton [mailto:niall.pemberton@blueyonder.co.uk]
Sent: Friday, March 26, 2004 8:55 PM
To: Struts Users Mailing List
Subject: Re: Struts Validator and Select boxes


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" <ja...@mphasis.com>
To: <st...@jakarta.apache.org>
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: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org





---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


html:link page syntax question

Posted by Frank Nguyen <fr...@sbcglobal.net>.
Hi,

I would like to write a simple code like:

...
<html:link page="/X.do"> 
  <bean:write name="A" property="b"/>
</html:link>
...

where X is String of property 'a' of bean 'A'. 

Do you know what is the syntax ? I tried something like: 

<html:link page='<bean:write name="A" property="a">.do'> 

but it didn't work.

Thanks in advance.

-Frank


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Struts Validator and Select boxes

Posted by Niall Pemberton <ni...@blueyonder.co.uk>.
All the properties you have defined for the form in the struts-config are
named differently from whats in your validation.xml - for example you have
"fromDay" in your validation.xml, but in the struts-config.xml the property
is "dayFrom"

Niall

----- Original Message ----- 
From: "Janarthan Sathiamurthy" <ja...@mphasis.com>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Saturday, March 27, 2004 5:57 AM
Subject: RE: Struts Validator and Select boxes


Hi Niall,

I am attaching the validation.xml and the jsp that i have used.
I have done the exact thing that you had specified earlier before posting
to the mailing list.
I am not clear where i am going wrong.

The Struts-config entry goes like -
<form-bean name="ocsReportForm"
type="org.apache.struts.validator.DynaValidatorActionForm">
<form-property name="monthFrom" type="java.lang.String" />
<form-property name="dayFrom" type="java.lang.String" />
<form-property name="yearFrom" type="java.lang.String" />
<form-property name="monthTo" type="java.lang.String" />
<form-property name="dayTo" type="java.lang.String" />
<form-property name="yearTo" type="java.lang.String" />
<form-property name="actionType" type="java.lang.String" />
<form-property name="pageNumber" type="java.lang.String" />
<form-property name="numberOfRows" type="java.lang.String" />
<form-property name="dateFrom" type="java.lang.String" />
<form-property name="dateTo" type="java.lang.String" />
</form-bean>

Regards,
Janarthan S

-----Original Message-----
From: Niall Pemberton [mailto:niall.pemberton@blueyonder.co.uk]
Sent: Friday, March 26, 2004 8:55 PM
To: Struts Users Mailing List
Subject: Re: Struts Validator and Select boxes


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" <ja...@mphasis.com>
To: <st...@jakarta.apache.org>
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: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org





---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org





> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org