Uploaded image for project: 'ZK'
  1. ZK
  2. ZK-4987

Listbox using form object as model doesn't resolve selectedItems

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Normal Normal
    • None
    • 9.6.0
    • None
    • Security Level: Jimmy
    • None

      Steps to Reproduce

      https://zkfiddle.org/sample/3nptg2s/5-Listbox-selectedItems-form-binding

       

      Run fiddle

      In the Section B - Form binding, click the "select first item" button

      Current Result

      item is added to the selection list (below), load binding triggers on Listbox's selectedItems attribute, but selection is not changed in the Listbox with model (B-2).

      Expected Result

      Selection status changes for selected items.

      Debug Information

      As this stage, the listitem value is a FormProxyObject of the data.

      Since the default ListboxSelectedItemsConverter implementation will use model.contains(bean) or check (listItems values).contains(bean), and there is no equality between the formProxyObject and the origin bean, the converter will not change the selection state of the listitems.

      Workaround

      If the content of the data items located in the model do not change (only the model as a list), then the model can be marked with the @immutableItems annotation.

       

      Otherwise, a custom converter based on the original ListboxSelectedItemsConverter can be implemented (see workaround section in fiddle)

            Jenkins Jenkins
            MDuchemin MDuchemin
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: