Can you please tell me, and if you can, how to, write code in thymeleaf for a drop-down list of roles (UserCriteria.roles) in which you can select several of these roles.

The following code is available:

<div class="container"> <div class="row"> <div class="col-md-2" style="padding-bottom: 10px"> <input id="showFilters" type="button" class="btn btn-default" th:value="#{StudentController.filters}"/> </div> </div> <div class="row" hidden="hidden" id="searchForm"> <form id="searchForm"> <div class="col-md-12 well"> <!--/*@thymesVar id="user" type="com.jborned.vverh.service.dto.UserDTO"*/--> <!--/*@thymesVar id="userRole" type="com.jborned.vverh.db.model.UserRole"*/--> <div class="row"> <div class="col-xs-3 form-group"> <input id="firstName" type="text" class="form-control" th:placeholder="#{UserController.name}" name="firstName" th:value="${userCriteria.firstName}"/> </div> <div class="col-xs-3 form-group"> <input id="lastName" type="text" class="form-control" th:placeholder="#{UserController.surname}" name="lastName" th:value="${userCriteria.lastName}"/> </div> <div class="col-xs-3 form-group"> <input id="email" type="text" class="form-control" th:placeholder="#{UserController.mail}" name="email" th:value="${userCriteria.email}"/> </div> <div class="col-xs-3 form-group"> <select name="enabled" id="enabled_input" class="form-control"> <option value="true" th:selected="${userCriteria.enabled == true}" th:text="#{yes}"></option> <option value="false" th:selected="${userCriteria.enabled == false}" th:text="#{no}"></option> <option value="" th:selected="${userCriteria.enabled == null}" th:text="#{soso}"></option> </select> </div> <div class="row"> <div class="col-md-12" align="center"> <input type="submit" style="margin-right: 10px" class="btn btn-default filters" th:value="#{apply}"/> <input id="clearButton" type="button" style="margin-left: 10px" class="btn btn-primary" th:value="#{clear}"/> </div> </div> </div> </div> </form> </div> </div> 

.

 @Data @Accessors(chain = true) public class UserCriteria implements SearchCriteria { private String firstName; private String lastName; private String email; private Boolean enabled = true; private Set<UserRole> roles; //todo } 

.

 @Controller @Secured("ROLE_ADMIN") @RequestMapping(USERS) public class UserController extends BaseController { @Autowired private UserService userService; @Autowired private UserValidator userValidator; @RequestMapping(value = LISTING) public String userListing(@ModelAttribute("userCriteria") UserCriteria userCriteria, Pageable pageable, @RequestParam(required = false) String successAddUser, Model model) { Page<UserListingDTO> users = userService.getAllUsersForListing(pageable, userCriteria); model.addAttribute("userListing", users); if (successAddUser != null) { model.addAttribute("successAddUser", true); } return "user/users"; } } 

Result:

enter image description here

I am trying to add a similar window below existing ones, but so far it does not go out.

  • You can download the list by select. - Roman C
  • Posted by select, swears at th: selected in the <option th: value = "COUCH" th: selected = "$ {userCriteria.roles.equals ('COUCH')}" th: text = "# {user.couch}" block > </ option> - Anton

0