Announcement Announcement Module
Collapse
No announcement yet.
How to handle more than tow submit button in SimpleFormController? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    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".

    Comment

    Working...
    X