I have a JSP page, which has a list of dropdown items. I am populating this dropdown with a request attribute of list type and looping through that one.
<select class="form-control" id="groupname" name="groupname">
<c:forEach items="${visibility}" var="groupListItem">
<option value="${groupListItem.groupName}">${groupListItem.groupName}</option>
</c:forEach>
</select>
Whenever I select an item from the dropdown, I need to display a list of checkboxes on the same page. The label and checked/unchecked values of the checkboxes are also part of the list attribute, groupListItem
.
The list attribute is a custom bean which has a map with checkbox names and values which decide if checked or unchecked.
How can I get the values for checkboxes when a drop down value is selected?
My list attribute looks like below.
List<GroupVisibilityBean> groupList = driverDAO.getGroupVisibility();
model.addAttribute("visibility", createGroup());
private List<GroupVisibilityBean> createGroup() {
List<GroupVisibilityBean> groupList = new ArrayList<GroupVisibilityBean>();
GroupVisibilityBean bean1 = new GroupVisibilityBean();
bean1.setGroupName("GARDA");
Map<String, String> map1 = new HashMap<String, String>();
map1.put("Personal Details", "Y");
map1.put("Driver Details", "N");
GroupVisibilityBean bean2 = new GroupVisibilityBean();
bean2.setGroupName("COURT");
Map<String, String> map2 = new HashMap<String, String>();
map2.put("Personal Details", "Y");
map2.put("Driver Details", "N");
groupList.add(bean1);
groupList.add(bean2);
return groupList;
}
Can someone please help me here?