Results 1 to 2 of 2

Thread: How to handle more than tow submit button in SimpleFormController?

  1. #1
    Join Date
    Jun 2007
    Posts
    159

    Default How to handle more than tow submit button in SimpleFormController?

    Assumed I have two submit button in the jsp as follow:
    Code:
    ...
    <form:form action="test-detail.html" method="post">
    ...
    <input name="button1" type="submit" value="Do Print"/>
    <input name="button2" type="submit" value="Do SendEmail"/>
    ...
    And the controller looks as follow:
    Code:
    ...
    public class TestController extends MQController {
    
    ...
    
    	@Override
    	protected ModelAndView onSubmit(HttpServletRequest request,
    			HttpServletResponse response, Object command, BindException errors)
    			throws Exception {
                   ....
    		return new ModelAndView(getSuccessView(), model);
    	}
    }
    How can I catch the different submit request in the controller?

  2. #2

    Default

    Easiest way is to check which button comes through in the request parameters. If button1 is clicked, there'll be an item in the request parameters with a key of "button1" and a value of "Do Print".

Posting Permissions

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