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

Combobox (drop down list with auto-complete) will not populate the list corrrectly while binded to different objects in random pattern

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Normal Normal
    • None
    • 6.5.5
    • Components, Databind
    • None
    • windows 8, jdk 7, tomcat 7

      While clicking on the 'Edit' button randomly for more than 4 or 5 times, the
      list returned to combobox started to appear incorrectly.

      The behavior like it would cache the selected item of previous binding for label.
      When I print to the selected item of current binding, it display correctly.
      Please refer to the attached MVVM example for details.

      My current work around is to overwrite the onInitRender method of org.zkoss.zul.Combobox with below logic :
      public void onInitRender(Event data) {
      //Bug #2010389
      removeAttribute("zul.Combobox.ON_INITRENDER"); //clear syncModel flag
      final Renderer renderer = new Renderer();
      final List<Object> subModel =
      _model instanceof ListSubModel ? new ArrayList<Object>(): null;
      final ListModel subset = syncModel(data.getData() != null ?
      data.getData() : getRawText());
      try {
      int pgsz = subset.getSize(), ofs = 0, j = 0;
      for (Comboitem item = getItems().size() <= ofs ? null: getItems().get(ofs), nxt;
      j < pgsz && item != null; ++j, item = nxt)

      { nxt = (Comboitem)item.getNextSibling(); //store it first final int index = j + ofs; final Object value = subset.getElementAt(index); if (subModel != null) subModel.add(value); renderer.render(item, value, index); }

      if (subModel != null)
      _subModel = subModel.toArray(new Object[subModel.size()]);
      } catch (Throwable ex)

      { renderer.doCatch(ex); }

      finally

      { renderer.doFinally(); }

      //added by cheong at 16/04/2014 to solve the caching problem
      if (subModel.size() == 1)

      { this.setText(subModel.get(0).toString()); }

      //end added by cheong at 16/04/2014 to solve the caching problem
      Events.postEvent("onInitRenderLater", this, null);// notify databinding load-when.
      Events.postEvent(ZulEvents.ON_AFTER_RENDER, this, null);// notify the combobox when items have been rendered.
      }

        1. comboBoxBug.JPG
          98 kB
          feicsh

            Unassigned Unassigned
            feicsh feicsh
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: