You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Robert Miller <rm...@ofumic.com> on 2004/08/19 21:24:44 UTC
Conditionally Validating an Entire Form Based Upon the button
pressed
I have a form which has a "save" (<html:submit ...) and "continue"
(<html:cancel ...) button.
The "save" should validate and process the data in the form.
The "continue" button should go to the next page, skipping any
validation and processing.
I have been using the validator plugin, with all of my validation in
the validation.xml file.
My form bean extends ValidatorForm and my validate function is
commented out (is not overriding the parent).
This validates great but will not allow me to skip validation on
"continue".
I have searched Google for conditional validation and only found how to
conditionally validate "required" fields based upon the values of other
fields.
Any ideas or suggestions?
Thanks.
Robert
Re: Conditionally Validating an Entire Form Based Upon the button pressed
Posted by Kishore Senji <ks...@gmail.com>.
Instead of commenting out your validate() method
You can do something like this
public ActionErrors validate(ActionMapping mapping, HttpServletRequest request){
ActionErrors errors = super.validate(mapping, request);
// If we see the cancel key in the request, since your continue button
is a cancel,
// return null
if(StringUtils.isNotEmpty(request.getParameter(org.apache.struts.taglib.html.Constants.CANCEL_PROPERTY
))){
return null;
}
return errors;
}
Thanks,
Kishore Senji.
On Thu, 19 Aug 2004 14:24:44 -0500, Robert Miller <rm...@ofumic.com> wrote:
> I have a form which has a "save" (<html:submit ...) and "continue"
> (<html:cancel ...) button.
> The "save" should validate and process the data in the form.
> The "continue" button should go to the next page, skipping any
> validation and processing.
>
> I have been using the validator plugin, with all of my validation in
> the validation.xml file.
> My form bean extends ValidatorForm and my validate function is
> commented out (is not overriding the parent).
>
> This validates great but will not allow me to skip validation on
> "continue".
>
> I have searched Google for conditional validation and only found how to
> conditionally validate "required" fields based upon the values of other
> fields.
>
> Any ideas or suggestions?
>
> Thanks.
> Robert
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Conditionally Validating an Entire Form Based Upon the button pressed
Posted by struts lover <st...@yahoo.com>.
Extend your action class from
ValidatorLookupdispatchAction class by Brandon
Goodin.
_______________________________
Do you Yahoo!?
Win 1 of 4,000 free domain names from Yahoo! Enter now.
http://promotions.yahoo.com/goldrush
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org