You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Rafael Taboada <ka...@gmail.com> on 2005/07/11 22:49:13 UTC
Validation problem
Hi folks, I'm doing my validation for my form fields...
I use validation framework, so I don't use validate method in my form bean.
The problem I have is the validate is called when I use for first time the
module. I mean, when I see for frst ime the HTML form, validation is
called... Why???
When I set validate attribute to false in my action mapping, validation is
not called...
I want the validation is called only when the user click on submit button.
Did u have the same problem???
My Action extend DispatchAction class.
Thanks in advance.
--
Rafael Taboada
Software Engineer
Cell : +511-97753290
"No creo en el destino pues no me gusta tener la idea de controlar mi vida"
Re: Validation problem
Posted by Michael Jouravlev <jm...@gmail.com>.
Rafael, turn validation off and call form.validate() manually from
your event handler method.
Michael.
On 7/11/05, Rafael Taboada <ka...@gmail.com> wrote:
> Hi folks, I'm doing my validation for my form fields...
> I use validation framework, so I don't use validate method in my form bean.
> The problem I have is the validate is called when I use for first time the
> module. I mean, when I see for frst ime the HTML form, validation is
> called... Why???
> When I set validate attribute to false in my action mapping, validation is
> not called...
> I want the validation is called only when the user click on submit button.
> Did u have the same problem???
> My Action extend DispatchAction class.
> Thanks in advance.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Validation problem
Posted by Borislav Sabev <b....@eventsoft.de>.
Rafael Taboada wrote:
>Hi folks, I'm doing my validation for my form fields...
> I use validation framework, so I don't use validate method in my form bean.
> The problem I have is the validate is called when I use for first time the
>module. I mean, when I see for frst ime the HTML form, validation is
>called... Why???
> When I set validate attribute to false in my action mapping, validation is
>not called...
> I want the validation is called only when the user click on submit button.
> Did u have the same problem???
> My Action extend DispatchAction class.
> Thanks in advance.
>
>
>
Use 2 actions - one that shows the form and one that submit it, and
validate the form ONLY on the second action (set the "validate"
attribute in struts-config.xml to false or true respectively) This is a
very common pattern in Struts.
If you use a DispatchAction (or derived from) to show and submit the
form, than you have 2 choices:
1. the suggested upper (add just a smal forward action when you want to
show the form)
2. recognize which "method" of the action (view or submit) is called -
you can find it in the reuest, passed to validate() - and then make the
validation only in case of submit.
Regards
Borislav