0

Weird ZK listbox bug?

asked 2011-09-06 08:23:55 +0800

valmar gravatar image valmar
925 2 13
http://www.timo-ernst.net

When I select multiple items in Listbox by holding the shift key, the wrong items are getting marked.

Some days ago this was working fine but now all out of sudden this weird behavior started occurring. Is it a ZK bug?

See the problem in action: http://www.youtube.com/watch?v=wOVMo519KQA

delete flag offensive retag edit

13 Replies

Sort by ยป oldest newest

answered 2011-09-06 20:13:23 +0800

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

I tested on a simple zk listbox in 508, no such issue.
which zk do you use?
could you provide a simple reproducible code and steps? then we can judge it is a bug or not

link publish delete flag offensive edit

answered 2011-09-07 02:57:33 +0800

valmar gravatar image valmar
925 2 13
http://www.timo-ernst.net

Hi,
I am using 5.0.8 as well. That problem existed in 5.0.7.1 too.

You're right, with a "plain" listbox the problem doesn't occur.
It seems like the listbox is conflicting with something else in my application. Unfortunately it's very difficult for me to isolate the code to create some sample code since it's a pretty big project with many dependencies.

However, I once already experienced this problem and that was when I attached a listener for key press events for each Listitem (was checking if the user was holding the Ctrl or shift key when he clicked on an item).
After removing the listener the problem was gone.

Now some weeks later, I still don't have registered such an event listener but all out of sudden the problem is back again.

Does this make any sense to you?

link publish delete flag offensive edit

answered 2011-09-07 09:12:49 +0800

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

could you provide some code snippet of that listener? the event it listens, and the code it handles

link publish delete flag offensive edit

answered 2011-09-07 12:01:04 +0800

valmar gravatar image valmar
925 2 13
http://www.timo-ernst.net

I found out what the problem is!

Once I click the first time on a listitem, it gets selected and I show a preview of the email in the box below the listbox (see video).

If I do that, the listbox looses focus.

If I now hold shift and click another listitem, the weird behavior occurs.

If I click the already selected listitem (before holding shift), the listbox gets back focus and the problem does not occur.

Sounds like a ZK bug to me.

link publish delete flag offensive edit

answered 2011-09-08 08:26:21 +0800

valmar gravatar image valmar
925 2 13
http://www.timo-ernst.net

No idea?
I already tried to manually re-set focus by calling listbox.setFocus(true) but that doesn't do the trick since the "preview" box on the bottom seems to get focus after the call to listbox.setFocus(true) :-(

link publish delete flag offensive edit

answered 2011-09-13 03:41:17 +0800

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

I try to simplify your issue, however, maybe it is too simple, it works fine in zksandbox, 5.0.8 env.
could you try to provide some code that close your real case?

<zk>
	<zscript>
		ListModel strset = new org.zkoss.zksandbox.grid.FakeListModel(20000);
	</zscript>
	<listbox id="list" width="200px" rows="10" model="${strset}" onSelect="btn.setFocus(true)" multiple="true">
		<listhead>
			<listheader label="Load on Demend" sort="auto"/>
		</listhead>
	</listbox>
	<button id="btn" label="focus"/>
</zk>

link publish delete flag offensive edit

answered 2011-09-13 09:51:09 +0800

valmar gravatar image valmar
925 2 13
http://www.timo-ernst.net

updated 2011-09-13 11:26:03 +0800

Damn, you're right!
I just created a new ZK project to replicate the issue but I didn't succeed :-(

That's very strange.

In my original code, when I remove the one line which starts the email's preview, everything works smoothly but with that line, Listbox starts this weird behavior. I'll then have to RE-CLICK the selected item to given the Listbox focus and then multiple selection via the shift key works.. I don't get it.

link publish delete flag offensive edit

answered 2011-09-13 13:13:10 +0800

valmar gravatar image valmar
925 2 13
http://www.timo-ernst.net

updated 2011-09-13 13:15:16 +0800

I finally found the source for the problem and I was able to reproduce it!

Download this ZK project and run it: http://dl.dropbox.com/u/17844821/zeug/ListboxBug.zip

To reproduce, follow these steps EXACTLY:

1. Click one of the items in the listbox
2. A second listbox should appear at the bottom
3. Hold shift and click another list item in the UPPER listbox
4. The "bug" should appear

I was also able to find the function which causes this problem. It's the method "invalidateAll()" in src/com/Controller.java.
If you comment it out, the Listbox behavior returns to normal.
Unfortunately, in my real application, I need this method to fix a UI issue.

link publish delete flag offensive edit

answered 2011-09-13 22:25:05 +0800

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

ok, the problem is now reproducible

<zk>
	<zscript>
		ListModel strset = new org.zkoss.zksandbox.grid.FakeListModel(20000);
	</zscript>
	<listbox id="list" width="200px" rows="10" model="${strset}" onSelect="list.invalidate()" multiple="true">
		<listhead>
			<listheader label="Load on Demend" sort="auto"/>
		</listhead>
	</listbox>
	<button id="btn" label="focus"/>
</zk>

I think this is some kind of 'bug', I will post to tracker.
however why do you need to invalidate a listbox when click it? and in the code that you shared, you almost invalidate all the page in invalidateAll. this is not efficient.(and , if you invalidate a parent, then you don't need to invalidate it's child)
can you just invalidate the part that need to be invalidate.

link publish delete flag offensive edit

answered 2011-09-13 22:40:18 +0800

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

bug posted, http://tracker.zkoss.org/browse/ZK-418

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: 2011-09-06 08:23:55 +0800

Seen: 1,023 times

Last updated: Sep 14 '11

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