0

Listbox getSelectedItems wrong order with ZK 6

asked 2012-02-15 15:23:59 +0800

Neus gravatar image Neus
1415 14

updated 2012-02-15 15:25:13 +0800

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:

ZKFiddle-Link

TestComposer.java
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");
}
}


index.zul
<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!

delete flag offensive retag edit

1 Reply

Sort by ยป oldest newest

answered 2012-03-02 03:02:56 +0800

hawk gravatar image hawk
3250 1 5
http://hawkphoenix.blogsp... ZK Team

Hi,
I have created a issue for this.
http://tracker.zkoss.org/browse/ZK-904

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2012-02-15 15:23:59 +0800

Seen: 439 times

Last updated: Mar 02 '12

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More