Uploaded image for project: 'Wicket'
  1. Wicket
  2. WICKET-2853

ListMultipleChoice/CheckBoxMultipleChoice do not retain selected but disabled items

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 1.4.8
    • 1.4.9, 1.5-M1
    • wicket
    • None

    Description

      Suppose in a shop application the user gets to choose from a number of options for the product, presented by checkboxes. One or more of these options may be mandatory for the given product, so they are not only pre-selected in the model and thus checked on the displayed page, but also disabled via #isDisabled, so they cannot be deselected.

      On form submit the browser (correctly) does not post these disabled values again and ListMultipleChoice#convertChoiceIdsToChoices does not keep these values. Upon re-displaying of the page the checkbox is no longer checked, and the user can't even check it again, since it is disabled. The behavior is demonstrated in the test case contained in the attached patch.

      I propose the attached path to give ListMultipleChoice a new flag called retainDisabledSelected. Default in the patch is currently false, though I think it could also be set to true. If the flag is true, the patched convertChoiceIdsToChoices will go through the old model collection to check if any of the selected values were disabled. Any such values will be added to the new model collection. If the flag is false, the ListMultipleChoice will behave like before. The included testcase verifies the behavior for both flag settings.

      Attachments

        Activity

          People

            ivaynberg Igor Vaynberg
            cmenzel Carl-Eric Menzel
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: