0

having issue with Listbox selecting rows. after upgrading zk lib from 5.0.5 to 5.0.10.

asked 2012-01-20 15:17:13 +0800

xrehbam gravatar image xrehbam
15 1

I am having issue with Listbox selecting rows after upgrading zk lib from 5.0.5 to 5.0.10.
When I select multiple items in Listbox by holding the shift key getSelectedItems() method return 0 rows.
It’s returning selected rows if I use ctrl + click. In version 5.0.5 it’s selecting rows without any problems by
holding shift or ctrl
Use case.
1. Selecting row one.
2. Scrolling down to row 30.
3. Holding shift + click on row 30
4. All rows is selected
5. getSelectedItems().size() return 0

Here is sample of my code which working fine in 5.0.5

public void onSelect$lbProductGroup(ForwardEvent event)throws Exception{
Listbox listbox = (Listbox) event.getOrigin().getTarget();
Set<Listitem> listitems = (Set<Listitem>)listbox.getSelectedItems();
System.out.println("list size = " + listitems.size());
for (Listitem listitem : listitems) {
System.out.println("value = " + listitem.getValue().toString());
System.out.println("description = " + listitem.getLabel());
}
}

delete flag offensive retag edit

4 Replies

Sort by » oldest newest

answered 2012-02-06 04:32:28 +0800

dennis gravatar image dennis
3679 1 6
http://www.javaworld.com....

Hi
could you provide a example. I tried my case, it doesn't show this issue.

<zk>
	<zscript><![CDATA[
		java.util.List model = new ArrayList();
		for(int i=0;i<100;i++){
			model.add("Item "+i);
		}
		
		public void onSelect(){
			Set listitems = list.getSelectedItems();
			System.out.println("list size = " + listitems.size());
			for (Object listitem : listitems) {
				System.out.println("value = " + listitem.getValue());
			}
			
			
		}
	]]></zscript>
	<listbox id="list" width="200px" rows="10"  onSelect="onSelect()" multiple="true">
		<listhead>
			<listheader label="Load on Demend" sort="auto"/>
		</listhead>
		<listitem forEach="${model}" label="${each}" value="${each}"></listitem>
	</listbox>
</zk>

link publish delete flag offensive edit

answered 2012-02-06 04:35:10 +0800

dennis gravatar image dennis
3679 1 6
http://www.javaworld.com....

by the way, if you use model , you should get selection from model. not from listbox.getSelectedItem.

link publish delete flag offensive edit

answered 2012-02-15 07:59:31 +0800

gloe gravatar image gloe
24

I have the same problem. When I specify the Library Property "org.zkoss.zul.listbox.rod" in the zk.xml to "true", it works.

<library-property>
    <name>org.zkoss.zul.listbox.rod</name>
    <value>true</value>
</library-property>

link publish delete flag offensive edit

answered 2012-02-16 00:49:02 +0800

dennis gravatar image dennis
3679 1 6
http://www.javaworld.com....

you should use model to get the selection, not from listbox.getItems when use model,
if you use CE or EE version and enable ROD. listbox only maintain a sub-set of listitems , that is why you will get 0 when scroll down to the bottom.

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-01-20 15:17:13 +0800

Seen: 198 times

Last updated: Feb 16 '12

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