0
Here is my code 



<div class="panel-body">
                        <div id="pickList">
                            <div class="row">
                                <div class="col-sm-5">
                                    <select class="form-control pickListSelect pickListResult"
                                        style="width: 100%" multiple="multiple" id="existingAdminGroupMembers" th:field="*{adminGroup.members}">
                                        <!-- <option
                                            th:each="currentUser : ${add_user.adminGroup.currentMembers}"
                                            th:value="${currentUser}" th:text="${currentUser}"></option> -->
                                    </select>
                                </div>
                                <div class="col-sm-2 pickListButtons">
                                    <button class="pAdd btn btn-primary btn-sm">&gt;</button>
                                    <button class="pAddAll btn btn-primary btn-sm">&gt;&gt;</button>
                                    <button class="pRemove btn btn-primary btn-sm">&lt;</button>
                                    <button class="pRemoveAll btn btn-primary btn-sm">&lt;&lt;</button>
                                </div>
                                <div class="col-sm-5">
                                    <select class="form-control pickListSelect pickData"
                                        style="width: 100%" multiple="multiple" id="availableMembersForAdminGrp">
                                        <option
                                            th:each="adminUser : ${add_user.adminGroup.availableMembers}"
                                            th:value="${adminUser.userName}"
                                            th:text="${adminUser.userName}"></option>
                                        </select>
                                </div>
                            </div>
                        </div>

                    </div>


 public class Group {

private String groupName;
private List<User> availableMembers = new ArrayList<User>();
private List<String> currentMembers = new ArrayList<String>();
private String[] members;
}


    public class AddUser {
        private String clusterName;
        private String projectName;
        private Group adminGroup;
        private Group userGroup;
}



 Controller Class :

        model.addAttribute("add_user", addUser);

When I am trying to return model attribute back to the controller class using Post method, I am not able to retrieve data of the pickListResult from the th:field adminGroup.members .can you tell me what's the problem in the above code.

1 Answers1

0

Assuming yout model attribute is like this from controller side

model.addAttribute("add_user", group );

<select class="form-control pickListSelect pickData" style="width: 100%" multiple="multiple" id="admins" th:field="*{adminUser.userName}">
     <option th:each="adminUser : ${add_user.admins.members}"
        th:value="${adminUser.userName}"
        th:text="${adminUser.userName}"></option>
</select>

Refer this post for more detail

MyTwoCents
  • 7,284
  • 3
  • 24
  • 52