[richfaces-issues] [JBoss JIRA] Commented: (RF-10793) ExtendedDataTable selection with Ctrl+click does not correctly update selection backing bean without clicking first

David Serres (JIRA) jira-events at lists.jboss.org
Thu Mar 24 13:24:45 EDT 2011


    [ https://issues.jboss.org/browse/RF-10793?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12591640#comment-12591640 ] 

David Serres commented on RF-10793:
-----------------------------------

Hi guys,
I have the solution. In the class "TableSelectionRendererContributor" there is the following condition:

if (clientSelection.isReset() || clientSelection.isSelectAll()) {
    simpleSelection.clear();
}

That means that if  a "click" or a "Ctrl+a" has been done, the selection you had should be cleaned. This is done to remember the selection you had in case a click with Ctrl is made. The solution is to always make the "clear", as all data in the selection is always sent.
To fix the bug, you can comment the condition, or add a javascript file with the following code:

ExtendedDataTable.SelectionManager.prototype.processClick = function(event, rowIndex) {
		if (this.options.selectionMode == "none") {
			return;
		}

		var bSingleSelection = this.options.selectionMode == "single";

		if(!event.shiftKey) {
			this.shiftRow = null;
		}		
		var range;	
		
		if ( event.shiftKey && !event.ctrlKey && !bSingleSelection && !event.altKey) {
            var arr = $(this.prefix + ":n").rows[0].id.split(":");
            this.firstIndex = Number(arr[arr.length-1]);
			this.selectionFlag = "x";
			if(!this.shiftRow) {
				this.shiftRow = this.activeRow;
			}
			this.startRow = this.shiftRow;
			if (((this.startRow <= rowIndex) && (this.firstIndex <= this.startRow || rowIndex < this.firstIndex))
				|| (this.startRow > rowIndex && this.firstIndex < this.startRow && rowIndex <= this.firstIndex)) {
				this.endRow = rowIndex;
			} else {
				this.endRow = this.startRow;
				this.startRow = rowIndex;
			}
			if(this.startRow > this.endRow) { //bugfix
				//without this selection of first row with shift was broken
				var t = this.startRow;
				this.startRow = this.endRow;
				this.endRow = t;
			}
			range = [this.startRow, this.endRow];
			this.setSelection(range);		
		} else if (!event.shiftKey &&  event.ctrlKey && !event.altKey) {
			this.selectionFlag = "x"; //<------ ADDED THIS!!!!!!
			if (this.selection.isSelectedId(rowIndex)) {
				this.removeRowFromSelection(rowIndex);
			} else {
				if (!bSingleSelection || this.selection.size() == 0) {
					this.addRowToSelection(rowIndex);
				}
			}
		} else  if (!event.shiftKey && !event.ctrlKey && !event.altKey) {
			this.selectionFlag = "x";
			range = [rowIndex, rowIndex];
			this.setSelection(range);		
		}
		this.setActiveRow(rowIndex);
		if (event.shiftKey) {
			if (window.getSelection) {
				window.getSelection().removeAllRanges();
			} else if (document.selection) {
				document.selection.empty();
			}
		}
		this.selectionChanged(event);
	}

The value "x", should be added as "selectionFlag", as long as it is responsible of always reseting the simpleSelection.

Regards
David

> ExtendedDataTable selection with Ctrl+click does not correctly update selection backing bean without clicking first
> -------------------------------------------------------------------------------------------------------------------
>
>                 Key: RF-10793
>                 URL: https://issues.jboss.org/browse/RF-10793
>             Project: RichFaces
>          Issue Type: Bug
>      Security Level: Public(Everyone can see) 
>          Components: component-tables
>    Affects Versions: 3.3.3.Final
>         Environment: OS: SLES 10 SP2
> JBoss EAP 4.3.0.GA_CP03
> Application using JBoss Seam 2.1.2
>            Reporter: Eduard Ereza
>              Labels: extendedDataTable, richfaces, richfaces-showcase, selection
>
> Selecting rows with Ctrl+click on extendedDataTable just after rendering it (first time or reRender) selects them in the backing bean, but then deselecting the same rows with Ctrl+click does not deselect them in the backing bean. The same happens if there is a selection when the component is rendered: then, deselecting a value deselects it from the backing bean, but selecting it again does not select it in the backing bean.
> When you click (without Ctrl) for the first time, everything works as it should.
> This is also reproduceable on RichFaces Live Demo: http://livedemo.exadel.com/richfaces-demo/richfaces/extendedDataTable.jsf (see Steps to Reproduce).
> This is probably related to RF-8681.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira


More information about the richfaces-issues mailing list