java - Submit Map<String,Integer> Thymeleaf -
model has map(string,integer), 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 submit checkboxes state changes?
if using spring mvc application , thymeleaf view engine please check out section on dynamic forms , working them:
http://www.thymeleaf.org/doc/tutorials/2.1/thymeleafspring.html#dynamic-fields
essentially want have object have map variable within it, bind inputs against when hits controller.
e.g.
public class myobject { map<string, integer> mymap; // getters , setters }
Comments
Post a Comment