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);
|
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) {
|
public String submit(@Valid @ModelAttribute("employee") final Employee employee, final BindingResult result, final ModelMap model) {
|
||||||
if (result.hasErrors()) {
|
if (result.hasErrors()) {
|
||||||
return "error";
|
return "error";
|
||||||
@ -37,5 +37,11 @@ public class EmployeeController {
|
|||||||
employeeMap.put(employee.getId(), employee);
|
employeeMap.put(employee.getId(), employee);
|
||||||
return "employeeView";
|
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>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<h3>Welcome, Enter The Employee Details</h3>
|
<h3>Welcome, Enter The Employee Details</h3>
|
||||||
|
<h4>${message}</h4>
|
||||||
|
|
||||||
<form:form method="POST" action="${pageContext.request.contextPath}/addEmployee" modelAttribute="employee">
|
<form:form method="POST" action="${pageContext.request.contextPath}/addEmployee" modelAttribute="employee">
|
||||||
<table>
|
<table>
|
||||||
@ -23,7 +24,8 @@
|
|||||||
<td><form:input path="contactNumber" /></td>
|
<td><form:input path="contactNumber" /></td>
|
||||||
</tr>
|
</tr>
|
||||||
<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>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</form:form>
|
</form:form>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user