You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Sobkowski, Andrej" <An...@emergis.com> on 2001/12/06 23:51:00 UTC

Small addition to - RE: Struts Validator (dumb?) question

Just a quick addition to the message below (sorrysorrysorry): I realize that
I can simply call the validate(mapping, request) directly in the Action, but
this is what I'd like to avoid as it would somehow create a link between the
Action and the validation process. 

I'd like to keep the validation process distinct from the Action; if
possible, the call to the validate(..) method should be "hidden" and
automated. If it's not possible, I guess I'll survive... :)

Thanks.

Andrej

> -----Original Message-----
> From: Sobkowski, Andrej [mailto:Andrej.Sobkowski@emergis.com]
> Sent: Thursday, December 06, 2001 5:22 PM
> To: Jakarta Struts (Dev) (E-mail); Jakarta Struts (User) (E-mail)
> Subject: Struts Validator (dumb?) question
> 
> 
> Hello All,
> 
> I'm trying to use the Struts validator but it doesn't seem to 
> be working in
> my - relatively common - case.
> 
> I have a modify.jsp page that is displayed upon calling
> /modifyAction?command=init (using the DispatchAction). No 
> validation must be
> performed at this point. The user then enters some data and 
> submits the form
> to /modifyAction?command=update and at this point I clearly want the
> validation to be performed. I also have a search page that 
> can be called
> with /modifyAction?command=search (no validation, of course).
> 
> How can I do this?
> 
> I've tried the following:
> - myForm extends ValidatorForm and <form name="myForm ...> in
> validation.xml. 
> This doesn't work as the form is validated on the init method 
> (the blank
> modify.jsp is displayed the first time with an error message 
> saying "field
> required" as the validation is performed on the form)
> - myForm extends ValidatorActionForm and <form 
> name="/modifyAction" ...> in
> validation.xml
> This doesn't work because when I call the search page with
> /modifyAction?command=search, the validation is triggered (it matches
> "/modifyAction") and doesn't allow me to go to the search 
> page until the
> data is valid (which doesn't really make sense since I want to select
> something).
> 
> Do you have any suggestions? Is there a way I can do the 
> above with the
> Struts validator? Am I structuring my actions in the wrong 
> way? I think I
> need a "DispatchValidatorForm"... :)
> 
> Thank you for any help.
> 
> Andrej
> 
>