-
Bug
-
Resolution: Invalid
-
Normal
-
None
-
8.6.1
-
None
Steps to Reproduce
run the code, compare the 2 listboxes
<zk> <listbox id="lb1" multiple="true"/> <zscript><![CDATA[ ListModelList model = new ListModelList(); model.add("aaa"); model.add("bbb"); model.add("ccc"); lb1.setModel(model); lb1.setCheckmark(true); lb1.setMultiple(true); ]]></zscript> <listbox id="lb2"/> <zscript><![CDATA[ ListModelList model = new ListModelList(); model.add("aaa"); model.add("bbb"); model.add("ccc"); lb2.setModel(model); lb2.setCheckmark(true); lb2.setMultiple(true); ]]></zscript> </zk>
Current Result
lb1 -> radio buttons (single selection)
lb2 -> check boxes (multiple selection)
Expected Result
consistent results / documentation:
According to the javadocs ...
https://www.zkoss.org/javadoc/latest/zk/org/zkoss/zul/Listbox.html#setMultiple-boolean-
... setting/changing multiple is allowed when using a model.
-> both listboxes should render with multiple selection
The Component Reference states something different:
https://www.zkoss.org/wiki/ZK%20Component%20Reference/Data/Listbox#Enable_with_a_ListModel
(which also makes sense, since setting the model later overrides previous settings to)
A similar hint from the javadocs of Listbox:
[Since 6.0.0] If a model is set, whether the listbox allows the multiple selection depends on Selectable.setMultiple(boolean). In other words, the application shall not access listbox directly if a model is assigned. Rather, the application shall access the model directly.
Debug Info
Root Cause
https://github.com/zkoss/zk/blob/master/zul/src/org/zkoss/zul/Listbox.java#L766
For lb1 the call into the list model is ignored, since the multiple property has already been set from the zul file, and hasn't changed by applying the model.
Workaround (Recommended Usage)
use setMultiple on the listmodel when using a list model