You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Clayson, Jim" <Ji...@centrica.co.uk> on 2002/10/17 15:04:56 UTC

help please: Validator basic use

Hi I am attempting to use the date validation provided by the framework - I
am using struts1.1b2.

I think I must be missing something fairly fundamental but maybe someone
will be able to confirm what that is. The problem is when I enter garbage
into the form's date fields and submit them, I get no errors. How does one
usually display the errors when using the validator framework.

I have my validator-rules.xml and validation.xml config files in my
application's web-inf dir.

Their relevent contents are as follows:

validator-rules.xml

      <validator name="date"
            classname="org.apache.struts.util.StrutsValidator"
               method="validateDate"
         methodParams="java.lang.Object,
                       org.apache.commons.validator.ValidatorAction,
                       org.apache.commons.validator.Field,
                       org.apache.struts.action.ActionErrors,
                       javax.servlet.http.HttpServletRequest"
              depends="required"
                  msg="errors.date"
       jsFunctionName="DateValidations">

         <javascript><![CDATA[
            function validateDate(form) {
	....... etc

                return true;
            }]]>
         </javascript>

      </validator>

 and validation.xml:

   <formset>
      <form name="ReportForm">
         <field property="dateFrom" depends="date">
         	     <arg0 key="ReportForm.dateFrom"/>
         </field>    
         <field property="dateTo" depends="date">
         	     <arg0 key="ReportForm.dateTo"/>
         </field>
      </form>
   </formset>   

I have my action's validate attribute set to "true".

Are the above setup correctly?

Thanks
Jim



------------------------------------------------------------
The information contained in or attached to this email is
intended only for the use of the individual or entity to
which it is addressed. If you are not the intended
recipient, or a person responsible for delivering it to the
intended recipient, you are not authorised to and must not
disclose, copy, distribute, or retain this message or any
part of it. It may contain information which is confidential
and/or covered by legal professional or other privilege (or
other rules or laws with similar effect in jurisdictions
outside England and Wales).

The views expressed in this email are not necessarily the
views of Centrica plc, and the company, its directors,
officers or employees make no representation or accept any
liability for its accuracy or completeness unless expressly
stated to the contrary.


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: help please: Validator basic use

Posted by Dave Derry <dd...@acm.org>.
Is your form derived from ValidatorForm rather than ActionForm?


----- Original Message -----
From: "Clayson, Jim" <Ji...@centrica.co.uk>


> Hi I am attempting to use the date validation provided by the framework -
I
> am using struts1.1b2.
>
> I think I must be missing something fairly fundamental but maybe someone
> will be able to confirm what that is. The problem is when I enter garbage
> into the form's date fields and submit them, I get no errors. How does one
> usually display the errors when using the validator framework.
>
> I have my validator-rules.xml and validation.xml config files in my
> application's web-inf dir.
>
> Their relevent contents are as follows:
>
> validator-rules.xml
>
>       <validator name="date"
>             classname="org.apache.struts.util.StrutsValidator"
>                method="validateDate"
>          methodParams="java.lang.Object,
>                        org.apache.commons.validator.ValidatorAction,
>                        org.apache.commons.validator.Field,
>                        org.apache.struts.action.ActionErrors,
>                        javax.servlet.http.HttpServletRequest"
>               depends="required"
>                   msg="errors.date"
>        jsFunctionName="DateValidations">
>
>          <javascript><![CDATA[
>             function validateDate(form) {
> ....... etc
>
>                 return true;
>             }]]>
>          </javascript>
>
>       </validator>
>
>  and validation.xml:
>
>    <formset>
>       <form name="ReportForm">
>          <field property="dateFrom" depends="date">
>               <arg0 key="ReportForm.dateFrom"/>
>          </field>
>          <field property="dateTo" depends="date">
>               <arg0 key="ReportForm.dateTo"/>
>          </field>
>       </form>
>    </formset>
>
> I have my action's validate attribute set to "true".
>
> Are the above setup correctly?
>
> Thanks
> Jim



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>