I have single form with multiple submit buttons, each performs separate function like:
- Search
- Update
- Add
- Delete
All actions are POST, and use name
attribute in button tag mapped to params in Controller side. Everything is working fine so far.
Now I need to disable the click of button while form is getting submitted and on the server side db updates are completed and server reply back.
So using jquery
I added below code and then it stopped working.
JS
$('form').submit(function(e) {
$(this).find("button[type='submit']").attr('disabled',true);
});
HTML
<form id="formSecurity"
th:action="@{/security}" th:object="${securityDTO}" method="POST">
<div class="form-group col-md-6">
<div class="input-group">
<input class="form-control" type="text" th:field="*{secId}" id="secId" placeholder="Find by SecId..." />
<div class="input-group-append">
<button class="btn btn-primary" name="search" type="submit">Search</button>
</div>
</div>
...
</div>
...
</form>
Controller
@PostMapping(value="/security", params={"search"})
public String searchSecurity(final SecurityDTO securityDTO, final BindingResult result, Model model) {
...
}
@PostMapping(value="/security", params={"update"})
public String searchSecurity(final SecurityDTO securityDTO, final BindingResult result, Model model) {
...
}
@PostMapping(value="/security", params={"addRow"})
public String searchSecurity(final SecurityDTO securityDTO, final BindingResult result, Model model) {
...
}
@PostMapping(value="/security", params={"removeRow"})
public String searchSecurity(final SecurityDTO securityDTO, final BindingResult result, Model model) {
...
}
But now looks like name
params is not getting submitted. And I am getting below error:
WARN 16660 --- [nio-8989-exec-8] .w.s.m.s.DefaultHandlerExceptionResolver : Resolved [org.springframework.web.bind.UnsatisfiedServletRequestParameterException: Parameter conditions "search" OR "update" OR "addRow" OR "removeRow" not met for actual request parameters: secId={1234}]