Results 1 to 2 of 2

Thread: form:Checkbox issues

  1. #1

    Lightbulb form:Checkbox issues

    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
    Code:
    private Set<RoomFacilityItem> facilities = new HashSet<RoomFacilityItem>();
    and the class RoomFacilityItem overrides the toString()
    Code:
    @Override
       public String toString() {
          return String.valueOf(ID);
       }
    in the JSP page I have:
    Code:
    <form:checkbox id="roomGroup_${roomGroup.key}_check_${roomFacilities[k].ID}"
                path="roomGroups[${roomGroup.key}].facilities"
                value="${roomFacilities[k].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.

    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.
    --
    Davide

  2. #2

    Default

    updated: fixed by using an binder.registerCustomEditor and a PropertyEditorSupport.
    --
    Davide

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •