Page 1 of 1

Next bug with Tree 2.0.2

Posted: 26 May 2010, 16:17
by Oleg
Hi,

The next bug with the tree component in the current release is an empty selection if we click twice on the same tree node. The first click is ok. For second click we have empty params.get(selectionParam). See decode() method in the TreeRenderer

Code: Select all

if(params.containsKey(selectionParam)) {
			String selectedNodesValue = params.get(selectionParam);
			
			if(selectedNodesValue.equals(""))
				tree.setSelection(new TreeNode[0]);
			else {
				String[] selectedRowKeys = selectedNodesValue.split(",");
				TreeNode[] selectedNodes = new TreeNode[selectedRowKeys.length];
				TreeModel model = new TreeModel((TreeNode) tree.getValue());
				
				for(int i = 0 ; i < selectedRowKeys.length; i++) {
					selectedNodes[i] = treeExplorer.findTreeNode(selectedRowKeys[i], model);
					model.setRowIndex(-1);	//reset
				}
				
				tree.setSelection(selectedNodes);
			}
		}
For the second click on the same node we have tree.setSelection(new TreeNode[0]);

Re: Next bug with Tree 2.0.2

Posted: 26 May 2010, 20:56
by Oleg
It is always reproducable. Also here http://www.primefaces.org:8080/prime-sh ... Single.jsf. Simple click several times on some node. For each click I would expect a reload of area which is referencable with update attribute. But it's not possible. Selection is lost.

YUI TreeView doesn't have this behavior. I hope it's not PrimeFaces' feature :-) Do you need an issue ticket?

Re: Next bug with Tree 2.0.2

Posted: 30 May 2010, 13:04
by cagatay.civici
Yes, please create a ticket so we don't lose this one.

Re: Next bug with Tree 2.0.2

Posted: 30 May 2010, 18:44
by Oleg
cagatay.civici wrote:Yes, please create a ticket so we don't lose this one.
Done http://code.google.com/p/primefaces/iss ... ail?id=857

Re: Next bug with Tree 2.0.2

Posted: 30 May 2010, 22:26
by cagatay.civici
Great, thanks!

Re: Next bug with Tree 2.0.2

Posted: 14 Jun 2010, 15:14
by Oleg
Hello Cagatay,

I have found a simple working solution. You have a method handleNodeSelection in treeview.js. Write these lines at first

Code: Select all

	if (args.node.highlightState != 1) {
		this.onEventToggleHighlight(args);
	}
You had

Code: Select all

this.onEventToggleHighlight(args);
until now (without if-check). The entire method looks now:

Code: Select all

	if (args.node.highlightState != 1) {
		this.onEventToggleHighlight(args);
	}
	
	var selected,
	nodes = this.getNodesByProperty('highlightState', 1),
	rowKeys = [];
	
	if(nodes) {
		for(var i = 0; i < nodes.length; i++) {
			rowKeys.push(nodes[i].data.rowKey);
		}
		
		selected = rowKeys.join(",");
	} else {
		selected = "";
	}
	
	document.getElementById(this.clientId + "_selection").value = selected;
	
	return false;
Maybe you can fix this for the upcoming release. Many thanks.