You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Gao Ye Wei <ye...@ncsi.com.cn> on 2004/08/27 03:27:32 UTC

Which is better? Auto validate or Manual validate?

Hi, all:
	Which validate method is better? Declare the validate conditions in
the validation.xml or override the ActionForm.validate()?Thanks for your
respose!	

Best regards!
Gao Yewei
 
Email: ye_wei@ncsi.com.cn

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


Re: Which is better? Auto validate or Manual validate?

Posted by Matt Bathje <mp...@ntsource.com>.
> Which validate method is better? Declare the validate conditions in
> the validation.xml or override the ActionForm.validate()?Thanks for
your
> respose!
>

I don't know that it is better, but I prefer using the validator
framework to define all of my validations.

For me it makes it much more clear what is going on, as all my
validation code is basically in the same place. Also, when you have
validations that are the same, you don't have to define it in 2
different validate() methods - you already have the validation setup and
can just re-reference it.

It also has the added bonus of being able to define both client and
server side validations in the same place, which is extremely handy.


Matt


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


RE: Which is better? Auto validate or Manual validate?

Posted by Joe Germuska <Jo...@Germuska.com>.
At 1:44 PM +0800 8/27/04, Yves Sy wrote:
>When you use DynaValidatorForm, you don't really have a choice other
>than to use the Validator framework as you cannot override the
>validate() method. You can only override when you write your own
>ActionForm.

Well, you can certainly subclass a ValidatorForm and do your own 
validation plus a call to super.validate(...).

Regarding the original question: neither is "better".  The Validator 
framework provides easy configurable validation for common 
validations, and it provides a way (although one I find confusing) to 
add your own configurable validations.  It also is designed to 
provide fairly automatic client-side javascript validation in 
coordination with the <html:javascript> tag.

I would suggest that you start by trying to use the validator 
framework, and more specifically, the DynaValidatorForm and 
DynaValidatorActionForm.  It allows you to deal with the majority of 
forms without writing any supporting java code, either for carrying 
the values from the HttpServletRequest into Struts or for validation.

If you find it doesn't do everything you need, you can either write a 
pluggable validator, subclass the ValidatorForm (or 
DynaValidatorForm) or write your own subclass of ActionForm.

Hope this helps
	Joe

-- 
Joe Germuska            
Joe@Germuska.com  
http://blog.germuska.com    
"In fact, when I die, if I don't hear 'A Love Supreme,' I'll turn 
back; I'll know I'm in the wrong place."
    - Carlos Santana

RE: Which is better? Auto validate or Manual validate?

Posted by Yves Sy <yv...@ssip.com>.
When you use DynaValidatorForm, you don't really have a choice other
than to use the Validator framework as you cannot override the
validate() method. You can only override when you write your own
ActionForm.

Validating using the validator framework can help off-load traffic from
the server when you use the javascript validation as your first line of
defense. However, you should also back up your validation on the
server-side as well since malicious users can easily get around the
client-side validation.

Regards,
-Yves- 

> -----Original Message-----
> From: Gao Ye Wei [mailto:ye_wei@ncsi.com.cn]
> Sent: Friday, August 27, 2004 9:28 AM
> To: 'Struts Users Mailing List'
> Subject: Which is better? Auto validate or Manual validate?
> 
> Hi, all:
> 	Which validate method is better? Declare the validate conditions
in
> the validation.xml or override the ActionForm.validate()?Thanks for
your
> respose!
> 
> Best regards!
> Gao Yewei
> 
> Email: ye_wei@ncsi.com.cn
> 
> ---------------------------------------------------------------------
> 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