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

zul.sel.ItemIter will return non-item object if all items are visible(false) during init

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Normal Normal
    • 8.6.0
    • 8.5.2
    • None
    • Security Level: Jimmy
    • None
    • ZK 8.6.0 S1, ZK 8.6.0 S2
    • None

      Steps to Reproduce

      Run fiddle:
      http://zkfiddle.org/sample/pg2al7/2-itemiter-returns-footer

      Current Result

      Listbox throw a
      "org.zkoss.zul.Listfoot cannot be cast to org.zkoss.zul.Listitem"
      exception during org.zkoss.zul.Listbox.renderItems(Set<? extends Listitem>)
      because it expects only listitems and received a listfooter instead

      Expected Result

      Client shouldn't send non-listitems to be rendered

      Debug Info

      set of items to render (which shouldn't contain Listfooter but does in this case) is sent to server by
      zul.mesh.MeshWidget.prototype._onRender

      During _onRender, the list of listitems is built using zul.sel.ItemIter which should only return listitems
      However, the ItemIter init will skip visible(false) children of listbox until it finds a child that is not visible(false).
      Since this is done using nextSibling, init will return any child, not just listitems

      Root Cause

      ItemIter init doesn't filter non-item children of mesh widget

      Workaround

      <script><![CDATA[
      	zk.afterLoad('zul.sel', function() {
      		var xItemIter = {};
      		zk.override(zul.sel.ItemIter.prototype, xItemIter ,{
      			_init: function () {
      				if (!this._isInit) {
      					this._isInit = true;
      					var p = this.box.firstItem;
      					if (this.opts && this.opts.skipHidden)
      						for (; p && !p.isVisible(); p = p.parent.nextItem(p)) {}
      					this.p = p;
      				}
      			}
      		});//zk.override
      	});//zk.afterLoad
      	]]></script>
      

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

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - 4 hours
                4h
                Remaining:
                Remaining Estimate - 4 hours
                4h
                Logged:
                Time Spent - Not Specified
                Not Specified