Hi

I think my situtation is kinda unique..
I have three buttons in a single form and my Action extends
LookupDispatchAction.

In my ExperimentForm (actionform), how do I disable validate if 'back'
is clicked?


struts-config.xml
------------------------------
<action name="experimentForm" path="/NewExperiment"
input="CreateExperiment.jsp" parameter="action" scope="request"
type="sg.edu.astar.flamingo.web.proteomics.view.NewExperimentAction">
      <forward name="addexperiment" path="/CreateExperiment.do"/>
      <forward name="next" path="/CreateProjectSummary.do"/>
      <forward name="back" path="/CreateProject.do"/>
    </action>

CreateExperiment.jsp
-----------------------------
<html:submit property="action" value="Back">
                  <bean:message key="button.back"/>
                </html:submit>
                </html:submit>
                
<html:submit property="action" value="Create Experiment">
                  <bean:message key="button.createexperiment"/>
                </html:submit>
                
<html:submit property="action" value="Next">
                  <bean:message key="button.next"/>
                </html:submit>

applicationresources.properties
----------------------------------------
button.createexperiment=Create Experiment
button.next=Next
button.back=Back

NewExperimentAction.java
-------------------------------------------
public class NewExperimentAction extends LookupDispatchAction 
{
  /**
   * This is the main action called from the Struts framework.
   * @param mapping The ActionMapping used to select this instance.
   * @param form The optional ActionForm bean for this request.
   * @param request The HTTP Request we are processing.
   * @param response The HTTP Response we are processing.
   * @return 
   * @throws java.io.IOException
   * @throws javax.servlet.ServletException
   */
 // public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws
IOException, ServletException
  //{
   // return mapping.findForward("success");
 // }
 
 protected Map getKeyMethodMap() 
 {
  Map map = new HashMap();
 map.put("button.createexperiment", "createExperiment");
 map.put("button.next", "next");
 map.put("button.back", "back");
 return map;
 }
 
 public ActionForward next(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws
IOException, ServletException
 {
 System.out.println("next()");
 return mapping.findForward("next");
 }
 
 public ActionForward back(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws
IOException, ServletException
 {
 System.out.println("back()");
 return mapping.findForward("back");
 }
 
  public ActionForward createExperiment(ActionMapping mapping,
ActionForm form, HttpServletRequest request, HttpServletResponse
response) throws IOException, ServletException
  {
  
  ExperimentForm experiment = (ExperimentForm) form;
  HttpSession session = request.getSession();
   Vector experiments =  (Vector) session.getAttribute("experiments");
  experiments.add(experiment);
  
    return mapping.findForward("addexperiment");
  }
 
}







On Tue, 2004-08-17 at 15:47, Kataria, Satish wrote:
> Map it to a different actionMapping and set validate="fasle";
> ie the submit and back button should have a different actionmapping
> 
> Satish
> 
> -----Original Message-----
> From: Sebastian Ho [mailto:[EMAIL PROTECTED] 
> Sent: Tuesday, August 17, 2004 1:14 PM
> To: Struts Users Mailing List
> Subject: Disable validate in actionForm
> 
> 
> hi
> 
> I have an validate method in my actionform and everything works fine. I
> added a 'Back' button in my webpage, and therefore validation is not
> necessary if the 'Back' button is clicked. Validation should occurs only
> if 'Next' is selected.
> 
> How do I stop struts from calling validate() is 'Back' is selected?
> 
> Note : Both buttons are in the same form.
> 
> Thanks
> 
> Sebastian
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to