-
Bug
-
Resolution: Fixed
-
Normal
-
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>