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

Setting model in onOpen listener of combobox causes "... cannot be cast to org.zkoss.zul.Comboitem" error

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: Normal
    • Resolution: Unresolved
    • Affects Version/s: 9.0.0, 8.6.3, 8.6.4
    • Fix Version/s: None
    • Component/s: None
    • Labels:

      Description

      Currently in our application (using ZK EE 7.0.5), for comboboxes we set the model in an onOpen listener so that the drop down list is always sourced from live data when the user opens the list. Also, in some cases the list may be restricted based on the values of other fields on the same page.

      We are trying to upgrade to ZK 8 and have been testing on ZK EE 8.6.3.

      We have a number of pages where a value selected from a combobox is used to limit records displayed in a listbox or grid. When using ZK 8 (8.6.3 or 8.6.4) or 9 (9.0.0), some of these pages will return a "{component} cannot be cast to org.zkoss.zul.Comboitem" at org.zkoss.zul.Combobox.service(Combobox.java:990). In some cases the error message can be reproduced consistently.

      Use attached zul and java files and the following steps to reproduce the error.

      1. Open test.zul
      2. Using the mouse drop down the category list and select "Category 2". The list below should now have 20 rows.
      3. Using the mouse drop down the category list and select "Category 3". The list below should be empty.
      4. Repeat step 2. An error message should appear see attached zk_combobox_error.png

      If the error message does not appear then increasing Category 2 list size (e.g. 200 instead of 20) then clicking the "Regenerate lists" button and repeating steps 2 to 4 may help.

      Debugging the code revealed that at line 990 Combobox.service was attempting to set the prevSeld to the listcell as noted in attached zk_combobox_list.png

      Note that, for pages in our application, the {component} which cannot be cast to org.zkoss.zul.Comboitem varies depending on what is displayed on the page (e.g. org.zkoss.zul.Hlayout, org.zkoss.zul.Label, org.zkoss.zul.Listcell, org.zkoss.zul.Listitem, org.zkoss.zul.Row)

      Note that this issue does not occur in ZK EE 7.0.5. We have not attempted to reproduced this issue in ZK 8 versions prior to 8.6.3.

        Attachments

        1. test.zul
          1.0 kB
        2. TestCombobox.java
          2 kB
        3. TestVM.java
          2 kB
        4. zk_combobox_error.png
          zk_combobox_error.png
          6 kB
        5. zk_combobox_list.png
          zk_combobox_list.png
          39 kB

          Activity

            People

            Assignee:
            Unassigned
            Reporter:
            Andrew69 Andrew69
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated: