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

FormComponent#inputChanged does not properly check enabled/disabled status of the component

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 1.4.9
    • 1.4.10, 1.5-M2.1
    • wicket
    • None

    Description

      We noticed this when we had a panel that contains a number of CheckBox components. Some of these CheckBoxes were checked, the underlying model boolean was true. The panel itself was set to disabled (isEnabled returned false), which correctly caused the checkboxes to be rendered with the attribute disabled="disabled". On a form submit, however, the previously checked boxes were rendered unchecked. Only the internal state of the CheckBox and the rendered HTML changed - the model value was not touched.

      After some debugging, I discovered the problem in FormComponent#inputChanged. That method only checks for isEnabled(), not isEnabledInHierarchy(). Since the CheckBox components themselves were enabled, they were accepting input. The browser, on the other hand, did not send anything, since the checkboxes were marked as disabled. This caused the CheckBox to receive null as its input, which it interprets as false/unchecked. The model was not affected since FormModelUpdateVisitor correctly checks isEnabledInHierarchy().

      Solution: FormComponent#inputChanged needs to call isEnabledInHierarchy instead of isEnabled.

      Attachments

        Issue Links

          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: