0

Bug with Checkmark ListBox and paging (ZK 5.0.5)

asked 2010-12-20 15:21:58 +0800

tregray gravatar image tregray
3

Hi all,

I've just started experimenting with ZK to see if it is suitable for a few simple webapps I'd like to put together. As such I've been playing around with tutorial code, sample applications etc and now started building something of my own. Unfortunately I seem to have stumbled across a bug (unless I've misunderstood a feature!). I'll document the steps to reproduce and what I've discovered below:

Scenario
-----------

A zul page containing a databound listbox. This list box has checkmark and multiple selection enabled, with the mold set to paging. Code looks something like this (I can't access my code at the minute, so please excuse some typos, "..." for other parameters I don't think are important here):

<window id="mywindow" apply="com.example.MyController" ..... >

<listbox model="@{mywindow$composer.data}" mold="paging" pagesize="10" checkmark="true" multiple="true" ....>
    <listhead>
        <listheader label="Column A"/>
        <listheader label="Column B"/>
        <listheader label="Column C"/>
    </listhead>
    <listitem self="@{each='data'}" value="@{data}">
        <listcell label="@{data.id}" />
        <listcell label="@{data.shortdescription}" />
        <listcell label="@{data.longdescription}" />
    </listitem>
</listbox>


Now assume that we have several pages of data when the application is actually running. The paging functionality nicely lets me move between these pages and the multiple and checkmark features allow me to multiply select data. This is where the problem shows up.


Problem Description
-------------------------

In the above scenario a user moves forward and backward between the listbox pages selecting and unselecting various rows. The user expects to be able to return to a page they have previously selected elements on and see them remain selected. Unfortunately it appears that occasionally this breaks down, leaving the user without any data selected except for on the page they last made a selection.


Investigation
-----------------

I created a class that extended the BindingListModel and overloaded the addSelection, clearSelection and removeSelection functions. The overloaded functions printed out a message indicating the function they were inside before calling their parents implementation.

Using this implementation of a BindingListModel I was able to see that as a user clicked on data I saw "In addSelection" messages in my debug output. Occasionally, I would also receive a "In clearSelection" message, followed by "In addSelection" for each selected element on the current page.

Investigating with a debugger I discovered that the client was sending back "clearFirst: true" as part of the JSON message before I saw the "In clearSelection" messages.

Starting with the ListBox javascript I followed the inheritance heirarchy back up to SelectWidget.js to locate the function "fireOnSelect" which mentions the "clearFirst" attribute (see below).
	fireOnSelect: function (ref, evt) {
		var data = [];

		for (var it = this.getSelectedItems(), j = it.length; j--;)
			if (it.isSelected())
				data.push(it);

		var edata, keep;
		if (evt) {
			edata = evt.data
			if (this._multiple)
				keep = edata.ctrlKey || edata.shiftKey || (evt.domTarget.id ? evt.domTarget.id.endsWith('-cm') : false);
		}

		this.fire('onSelect', zk.copy({items: data, reference: ref, clearFirst: !keep}, edata));
	}


The clearFirst attribute is set by the boolean condition "!keep". The keep variable is set by
keep = edata.ctrlKey || edata.shiftKey || (evt.domTarget.id ? evt.domTarget.id.endsWith('-cm') : false);


As such, the client will request the current selections to be cleared unless the user is holding down ctrl, shift or the domTarget id ends in "-cm" (I'm assuming that stands for checkmark).

Using the DOM inspector in Firefox I was able to determine that the only parts of my page whose domTarget id ends in "-cm" are the checkboxes themselves. However, users are able to select data by clicking anywhere on the row. The rest of the domTarget id's for the row do not end in "-cm" causing the client to request the currently selected items to be cleared unless the user clicks exactly on the checkbox itself. This behaviour is present in ZK 5.0.5 and also the latest freshly build of 5.0.6 that I downloaded.


Is this a confirmed bug I've missed looking at this forum, or is it a new one? I'd expect that the behaviour for this component would be that no matter where the user clicked in a row the selections made in all other pages would remain. Forcing the user to click exactly on the checkbox when the UI suggests otherwise seems extremely unfortunate.

Sorry for the length of the post, hope it all makes sense! Let us know if you need (even more!!) info.

delete flag offensive retag edit

5 Replies

Sort by ยป oldest newest

answered 2010-12-24 04:23:41 +0800

RyanWu gravatar image RyanWu
533 2
about.me/flyworld

@yaryan997 please create a new thread

link publish delete flag offensive edit

answered 2010-12-24 04:25:10 +0800

RyanWu gravatar image RyanWu
533 2
about.me/flyworld

Hi , tregray
i think the problem you point out might be a bug of ZK, you can post it to ZK Bug

link publish delete flag offensive edit

answered 2010-12-26 19:49:55 +0800

PeterKuo gravatar image PeterKuo
481 2

@yaryan997
Please don't cross post.
You should create a new thread in category "Help"

link publish delete flag offensive edit

answered 2010-12-26 22:47:51 +0800

yaryan997 gravatar image yaryan997
210 2

sorry friend for my wrong post at this point..

I have created a new thread in FORUM-> HELP

WITH THIS TITLE

how to get values from database to listbox with jpa query

PLZ HELP ME WITH THIS..

link publish delete flag offensive edit

answered 2011-07-13 02:07:23 +0800

cvarona gravatar image cvarona
554 1 6

Finally fixed!

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: 2010-12-20 15:21:58 +0800

Seen: 897 times

Last updated: Jul 13 '11

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