Tree with context menu how to get selected node

UI Components for JSF
Post Reply
olpf
Posts: 84
Joined: 25 Feb 2013, 16:49
Location: GER

12 Jan 2015, 13:06

Hi,

I have a tree with context menu. I registered an ajax event on tree node selection change..which work. But I have one problem: if I point the mouse over a tree node an click the right mouse button, the context menu is opened but the tree node selection event is not fired. So I do not have the information about the currently selected node. It only works if I click the left mouse button over a tree node and then the right mouse.
How can I achieve that the right click on a tree node fires the selection event before the context menu is shown?

Regards
Oliver
JBoss AS, Primefaces 5, Primefaces extensions 4.0.0

olpf
Posts: 84
Joined: 25 Feb 2013, 16:49
Location: GER

12 Jan 2015, 14:30

Maybe I should mention that the tree is inside a tab in a tab view and I have n tabs with each a tree inside. All trees define the same method in attribute "selection". Maybe this is the problem?
JBoss AS, Primefaces 5, Primefaces extensions 4.0.0

olpf
Posts: 84
Joined: 25 Feb 2013, 16:49
Location: GER

12 Jan 2015, 14:51

The method of the tree selection attribute is called for each tree in each tab. I am a little confused because I select in one specific tree...the the selection is set and afterwards the method is always executed with null valued tree node. So a click in the tree leads to the execution of the selection method for all trees? Is it not possible to have multiple trees on a page?
JBoss AS, Primefaces 5, Primefaces extensions 4.0.0

olpf
Posts: 84
Joined: 25 Feb 2013, 16:49
Location: GER

15 Jan 2015, 13:53

After a redesign of the ui I have only one tree at the same time, but the problem still exists. The selected node in the backing bean is not set when the context menu is opened or an item from the context menu is chosen. Only left mouse click sets the selected tree node in the backing bean. Any idea?

Code: Select all

<p:tree id="clTreeId" styleClass="tree" value="#{clController.getRoot(selCl.getName())}"
					var="element" selectionMode="single" draggable="true" droppable="true" dropRestrict="sibling"
					selection="#{selectionController.selectedTreeNode}" dynamic="false">

					<p:ajax event="select" update=":detailsFormId:clTreeDetailsOuterId" process="clTreeId" resetValues="true" />

					<p:treeNode type=...
					</p:treeNode>
					...
				</p:tree>

the tree is inside a p:layout.
JBoss AS, Primefaces 5, Primefaces extensions 4.0.0

olpf
Posts: 84
Joined: 25 Feb 2013, 16:49
Location: GER

15 Jan 2015, 14:26

Here is a context menu for the tree:

Code: Select all

<p:contextMenu id="cmDeleteChoiceId" for="clTreeId" nodeType="choice">
					<p:menuitem value="Delete" icon="fa fa-trash-o"
						actionListener="#{selectionController.deleteTreeSelection()}"  
						update="clTreeId" immediate="true" />
				</p:contextMenu>
I tried some variations with the "process" attribute of the p:contextMenu
empty: only deleteTreeSelection() called, selected tree node not set
@this: only deleteTreeSelection() called, selected tree node not set
clTreeId @this: only deleteTreeSelection() called, selected tree node not set
clTreeId: tree node selection is set but deleteTreeSelection() not called

I have no clue :(
JBoss AS, Primefaces 5, Primefaces extensions 4.0.0

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 12 guests