Results 1 to 4 of 4

Thread: using two submit buttons on same HTML form

  1. #1

    Default using two submit buttons on same HTML form

    Hello ,
    I have page with OK and Cancel submit button.
    I was using initially struts in that this Cancel pressed can be recognized by isCancel() method in Action class.

    Now i am not using struts and using spring's web MVC
    So how can i recognize if cancel is pressed using spring, jsp tags but not using struts tags.

    thank you
    -- mithun

  2. #2
    Join Date
    Aug 2004
    Location
    The Netherlands
    Posts
    160

    Default

    I am using it, this is some code that might help you

    This is a part of my SimpleFormController subclass

    Code:
    	protected ModelAndView processFormSubmission(HttpServletRequest request,
    			HttpServletResponse response, Object command, BindException errors)
    			throws Exception {
    		Order order = (Order)command;
    		String orderId = order.getId().toString();
            if (request.getParameter("cancel") != null) {
            	return new ModelAndView(new RedirectView(getBackView()));
            } else if (request.getParameter("edit") != null) {
            	String orderIdStr = "?id="+orderId;
            	return new ModelAndView(new RedirectView(getEditView()+orderIdStr));
            } else if (request.getParameter("orderinvoice") != null) {
            	String orderIdStr = "?orderid="+orderId+"&invoiceid=new";
            	return new ModelAndView(new RedirectView(getOrderInvoiceView()+orderIdStr));
            } 
    		return super.processFormSubmission(request, response, command, errors);
    	}
    And some code from the jsp
    Code:
    ...
    		<td>
    			<input type="submit" class="button" name="edit" value="<fmt:message key="general.edit"/>" onclick="bEdit=true"/>
    			<input type="submit" class="button" name="save" value="<fmt:message key="general.save"/>"/>
    			<input type="submit" class="button" name="cancel" value="<fmt:message key="general.back"/>" onclick="bCancel=true"/>
    			<input type="button" class="button" onClick="javascript:openPopup('showOrderConfirmation.html?orderId=${order.id}','<fmt:message key="order.bevestiging"/>');" value="<fmt:message key="order.bevestiging"/>"/> &nbsp;
    		</td>
    ...
    Jettro Coenradie
    http://www.gridshore.nl

  3. #3

    Default thank you for your code help

    hello ,
    thank you , i got my solution from code that you sent me.

    -- mithun

  4. #4

    Default CancellableFormController

    I guess you need CancellableFormController. It's a controller extended from SimpleFormController. It handles your cancel button easily. This class is provided since Spring 1.2.3.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •