-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hi,
I realize that with ZK 6 when getting selected items of a multiple listbox with listbox.getSelectedItems() they arrive disordered.
You can try it by yourself here:
package j261d7qp$v2;import org.zkoss.zk.ui.*;
import org.zkoss.zk.ui.event.*;
import org.zkoss.zk.ui.util.*;
import org.zkoss.zk.ui.ext.*;
import org.zkoss.zk.au.*;
import org.zkoss.zk.au.out.*;
import org.zkoss.zul.*;public class TestComposer extends GenericForwardComposer{
public void doAfterCompose(Component comp) throws Exception {
super.doAfterCompose(comp);}
public void onClick$btn(Event e) throws InterruptedException{
Messagebox.show("Hi btn");
}
}
<zk>
<window title="Livedata Demo" border="normal" width="300px">
<zscript><![CDATA[
String[] data = new String[30];
for(int j=0; j < data.length; ++j) {
data[j] = "item "+j;
}
ListModel strset = new SimpleListModel(data);
]]></zscript>
<listbox id="lb" rows="10" model="${strset}" multiple="true" checkmark="true">
<listhead>
<listheader label="Items"/>
</listhead>
</listbox>
<button label="Print">
<attribute name="onClick">
<![CDATA[
String sItems = "";
for(int i=0;i< lb.getSelectedCount();i++){
sItems = sItems + ((Listitem)lb.getSelectedItems().toArray()[i]).getLabel()+", ";
}
lb.setSelectedIndex(-1);
alert(sItems);
]]>
</attribute>
</button>
</window>
</zk>
Select some items and click on Print button. An alert will be shown with the label of the selected items. They are not in order! Maybe they are in the order you select them? Is there anyway to change it? In previous versions of ZK they appear in order (from the lowest index to the highest)
Thank you!
Hi,
I have created a issue for this.
http://tracker.zkoss.org/browse/ZK-904
Asked: 2012-02-15 15:23:59 +0800
Seen: 439 times
Last updated: Mar 02 '12