struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Zhang, Larry \(L.\)" <lzhan...@ford.com>
Subject RE: validator.xml usage
Date Tue, 01 Jun 2004 20:44:35 GMT
You can define you own validator if you like:

Say you define this in validation.xml (meaning you want to validate attributeA by myRequried()
method)

<formset>
         <form name="yourForm">        
              <field property="attributeA" depends="myRequried">
                     <arg0 key="yourForm.attributeA"/>
              </field>
         </form>
    </formset>

In your validator-rules.xml you define:

<validator name="myRequired"
            classname="webcontext.com.Validator" // change this to your own Validator class
               method="validateMyRequried"
         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.myRequired">
      </validator>


Now you should in your Validator.java define/code validateMyRequried() method and pass in
(java.lang.Object,
                       org.apache.commons.validator.ValidatorAction,
                       org.apache.commons.validator.Field,
                       org.apache.struts.action.ActionErrors,
                       javax.servlet.http.HttpServletRequest),

Hope this helps.

Larry Zhang

-----Original Message-----
From: gads zooks [mailto:gads_zooks@yahoo.com]
Sent: Tuesday, June 01, 2004 4:32 PM
To: Struts Users Mailing List
Subject: Re: validator.xml usage


that is true....if u want to use server side validation you can specify that in the 
struts-config.html
something like this
 
<action path="/Action"
            name="FormToBeValidated"
            validate="true"                          <----------- set true here
            parameter="function"
            input="somepage.jsp"   <--- goes to this page if validation fails
/>
 
if you want to use javascript too....with the same setup (validation.xml, validator-rules.xml)
u can add the <html:javascript/> tag to your jsp and it will show u the errors....there
are also <html:messages />  , u can check out the info at husted.com/struts site
 
hope this helps
 
amit


Rodrigo Oliveira <rodrigo.struts@icorp.com.br> wrote:
The validation.xml you put the rules for client and server validation. The
struts validator validate your forms based on same validation rules.

[]´s

Rodrigo Oliveira
rodrigo.struts@icorp.com.br


----- Original Message ----- 
From: 
To: 
Sent: Tuesday, June 01, 2004 5:15 PM
Subject: validator.xml usage


> Is the validator.xml just for client-side validation? Or also for
> server-side validation
>
>
> ---
> > Thanks...
> > Mick Knutson
> >
> > 525 Market Street, SF, CA 94103
> > (415) 222-1020
> > Mick.Knutson@WellsFargo.com
> > MAC A0103-223
> ---
>
>
>
> ---------------------------------------------------------------------
> 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

		
---------------------------------
Do you Yahoo!?
Friends.  Fun. Try the all-new Yahoo! Messenger

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


Mime
View raw message