Hi all,
I have been trying to make the form:checkbox working and I am halfway to success. I am using spring MVC 2.5 and I managed to display correctly the checkboxes in the JSP but it seems that they are NOT causing any effects on my collection back in the controller.
I have this collection of objects in the class RoomGroup
and the class RoomFacilityItem overrides the toString()Code:private Set<RoomFacilityItem> facilities = new HashSet<RoomFacilityItem>();
in the JSP page I have:Code:@Override public String toString() { return String.valueOf(ID); }
And all is appearing fine in the JSP. If there are some facilities assigned to a roomGroup, the checkboxes are correctly appearing selected in the HTML page.Code:<form:checkbox id="roomGroup_${roomGroup.key}_check_${roomFacilities[k].ID}" path="roomGroups[${roomGroup.key}].facilities" value="${roomFacilities[k].ID}" />
When I submit the page, it seems that I do not have any effect in the RoomGroup.facilities. Whatever was there before is still there. I cannot add/remove anything using the checkboxes on the page.
Since the RoomFacilityItem objects needs to be retrieved from the DB [I have already a service for this] it seems that I am missing a piece in the puzzle. I can understand that the ID are retrieved from the list by accessing the getID() method. But the opposite part is blurry to me.


. I am using spring MVC 2.5 and I managed to display correctly the checkboxes in the JSP but it seems that they are NOT causing any effects on my collection back in the controller.
Reply With Quote
