struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Cliff" <>
Subject Re: HOw to avoid validations for certain submit buttons on a single form?
Date Wed, 05 Jan 2005 01:46:04 GMT

You may get the reference from the Cancel Button in CancelTag.

The Tag will set a parameter in the request to block the validation in the

Good Luck

----- Original Message ----- 
From: "Krishna Mohan Radhakrishnan" <>
To: "Struts Users Mailing List" <>
Sent: Wednesday, January 05, 2005 12:27 AM
Subject: HOw to avoid validations for certain submit buttons on a single

Hi all,

I have a jsp called Plan.jsp. The name of the ActionForm is

There is a action class called From this it is forwarding to Plan.jsp.

In the Plan.jsp there are 2 buttons and one text field.

Text field name is txtboxTitle and the 2 buttons are "Add New Service
Level" and "Inactivate Plan". Both are buttons of type submit.

When I am clicking "Add New Service Level", the PlanActionForm is being
submitted to But when I am clicking the "Inactivate"
button the same form is submitted to is like this

public class InactivatePlanAction extends ValidationAction {

    public InactivatePlanAction() {


        super.setFormBean(new PlanActionForm());



    protected void doCustomValidation(ActionForm form, SessionState
state) {

      PlanActionForm planForm = (PlanActionForm) form;

      super.addError("Error happened");


    protected ActionForward doExecute(ActionMapping mapping, ActionForm
form, SessionState state) {

        PlanActionForm planForm = (PlanActionForm) form;

        String forwardTo = "success";

        return mapping.findForward(forwardTo);



The validator-rules.xml will look like this.

<form name="PlanActionForm">

                  <field property="txtboxTitle" depends="maxlength">

                  <msg name="maxlength" key="errors.offers.maxlength"/>

                  <arg1 name="maxlength" key="${var:maxlength}"







Struts-config.xml will look like this





            path=" /InactivatePlanAction"

                  type=" action.InactivatePlanAction"


            name="PlanActionForm" >

                <forward name="success" path /Plan.jsp"/>

                <forward name="ValidationError" path="/Plan.jsp" />


Here there is a text field validation for maximum length.

What I want is that when I am clicking the Inactivate button, it should
not do any form validations that is given in the validator-rules.xml. It
should directly go to the and display the
error message "Error happened".

But when I am clicking the "Add New Service Level" button the form has
to be validated according to that given in the validator-rules.xml.

Now what is happening is when I am clicking the Inactivate button, it is
doing the form validations too.

Does any body have any idea how to do it?

I think one solution is to put Inactivate in another ActionForm.

But can I achieve the result in a single Actionform.


Krishna Mohan

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message