dimanche 3 mars 2019

Thymeleaf many-to-many checkbox list

I am porting an application from JSP to Thymeleaf. So far i have found an equivalent to everything I was doing in JSP EXCEPT for this. I have a role entity that has a many-to-many relationship with the permission entity, probably a very typical setup. In JSP I used to be able to edit the role and map each permission to a checkbox, like this :

<form:checkboxes element="li" items="${systemPermissions}" path="permissions" itemValue="id" itemLabel="name" id="systemPermissions"/>

This takes a List object from the model and maps all the allowed permissions by checking each checkbox accordingly. Super simple, super concise, but unfortunately I am not finding a way to do this with Thymeleaf.

Is there a way with Thymeleaf to dynamically create a checkbox list and map a many-to-many relationship to it?

Thanks!




Aucun commentaire:

Enregistrer un commentaire