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

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -