Model has Map(String,Integer), this map displayed on page in checkboxes like:
<ul>
<li th:each="item : ${map}">
<input type="checkbox" th:checked="${item.value} == 1" th:id="${item.key}"/>
<label th:for="${item.key}" th:text="${item.key}"/>
</li>
</ul>
How should i submit checkboxes state changes?
If you are using Spring MVC as your application and Thymeleaf as your view engine please check out this section on dynamic forms and working with them:
http://www.thymeleaf.org/doc/tutorials/2.1/thymeleafspring.html#dynamic-fields
Essentially what you want to do is have an object that would have a Map as a variable within it, which would then bind all your inputs against when it hits the controller.
e.g.
public class MyObject {
Map<String, Integer> myMap;
// getters and setters
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With