Next bug with Tree 2.0.2

UI Components for JSF
Post Reply
User avatar
Oleg
Expert Member
Posts: 3805
Joined: 02 Oct 2009, 09:41
Location: Germany, Black Forest

26 May 2010, 16:17

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]);
PrimeFaces Cookbook (2. edition): http://ova2.github.io/primefaces-cookbook/ Learning Angular UI Development with PrimeNG: https://github.com/ova2/angular-develop ... th-primeng Blog: https://medium.com/@OlegVaraksin

User avatar
Oleg
Expert Member
Posts: 3805
Joined: 02 Oct 2009, 09:41
Location: Germany, Black Forest

26 May 2010, 20:56

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?
PrimeFaces Cookbook (2. edition): http://ova2.github.io/primefaces-cookbook/ Learning Angular UI Development with PrimeNG: https://github.com/ova2/angular-develop ... th-primeng Blog: https://medium.com/@OlegVaraksin

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

30 May 2010, 13:04

Yes, please create a ticket so we don't lose this one.

User avatar
Oleg
Expert Member
Posts: 3805
Joined: 02 Oct 2009, 09:41
Location: Germany, Black Forest

30 May 2010, 18:44

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
PrimeFaces Cookbook (2. edition): http://ova2.github.io/primefaces-cookbook/ Learning Angular UI Development with PrimeNG: https://github.com/ova2/angular-develop ... th-primeng Blog: https://medium.com/@OlegVaraksin

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

30 May 2010, 22:26

Great, thanks!

User avatar
Oleg
Expert Member
Posts: 3805
Joined: 02 Oct 2009, 09:41
Location: Germany, Black Forest

14 Jun 2010, 15:14

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.
PrimeFaces Cookbook (2. edition): http://ova2.github.io/primefaces-cookbook/ Learning Angular UI Development with PrimeNG: https://github.com/ova2/angular-develop ... th-primeng Blog: https://medium.com/@OlegVaraksin

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: Google [Bot] and 11 guests