BAEL-3820: Multiple submit button to a Form (#10457)
This commit is contained in:
parent
9ea990660e
commit
28fe37cac4
|
@ -26,7 +26,7 @@ public class EmployeeController {
|
|||
return employeeMap.get(Id);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/addEmployee", method = RequestMethod.POST)
|
||||
@RequestMapping(value = "/addEmployee", method = RequestMethod.POST, params = "submit")
|
||||
public String submit(@Valid @ModelAttribute("employee") final Employee employee, final BindingResult result, final ModelMap model) {
|
||||
if (result.hasErrors()) {
|
||||
return "error";
|
||||
|
@ -37,5 +37,11 @@ public class EmployeeController {
|
|||
employeeMap.put(employee.getId(), employee);
|
||||
return "employeeView";
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/addEmployee", method = RequestMethod.POST, params = "cancel")
|
||||
public String cancel(@Valid @ModelAttribute("employee") final Employee employee, final BindingResult result, final ModelMap model) {
|
||||
model.addAttribute("message", "You clicked cancel, please re-enter employee details:");
|
||||
return "employeeHome";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
</head>
|
||||
<body>
|
||||
<h3>Welcome, Enter The Employee Details</h3>
|
||||
<h4>${message}</h4>
|
||||
|
||||
<form:form method="POST" action="${pageContext.request.contextPath}/addEmployee" modelAttribute="employee">
|
||||
<table>
|
||||
|
@ -23,7 +24,8 @@
|
|||
<td><form:input path="contactNumber" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><input type="submit" value="Submit" /></td>
|
||||
<td><input type="submit" name="submit" value="Submit" /></td>
|
||||
<td><input type="submit" name="cancel" value="Cancel" /></td>
|
||||
</tr>
|
||||
</table>
|
||||
</form:form>
|
||||
|
|
Loading…
Reference in New Issue