Different ContextMenu for different nodeType doesn't work for Horizontal Tree #1920

akhilkalra opened this Issue Nov 23, 2016 · 7 comments


None yet

3 participants

akhilkalra commented Nov 23, 2016 edited

1) Environment

  • PrimeFaces version: 6.0
  • Does it work on the newest PrimeFaces version? NO
  • Application server + version: Jboss EAP 6.3.3
  • Affected browsers: Chrome

2) Expected behavior

In the horizontal tree, when user clicks on different node types different context menu should appear.

3) Actual behavior

In the horizontal tree, when user clicks on different node types SAME context menu is appearing.

This behaviour is working fine in the Primefaces version 5.3.

4) Steps to reproduce

Run the code and right click on the different levels of node, it will show always the same context menu, irrespective of nodeType.

5) Example Code

<p:tree id="objectClassMasterData" value="#{masterDataTreePM.root}" var="node" orientation="horizontal" dynamic="true" selectionMode="single">
<p:treeNode type="objectClass">
<p:inputText value="#{node}" required="true" label="text" />
<p:treeNode type="componentGroup">
<p:inputText value="#{node}" required="true" label="text" />
<p:treeNode type="component">
<p:inputText value="#{node}" required="true" label="text" />
<p:treeNode type="testObject">
<p:inputText value="#{node}" required="true" label="text" />
<p:treeNode type="testInstruction">
<p:inputText value="#{node}" required="true" label="text" />
<p:contextMenu for="objectClassMasterData" nodeType="objectClass" id="menuCompGrp">
<p:menuitem id="addCompGrp" value="Add X"/>
<p:contextMenu for="objectClassMasterData" nodeType="componentGroup" id="menuCompGrp1">
<p:menuitem id="editCompGrp" value="edit X" />
<p:menuitem id="deleteCompGrp" value="delete X"/>
<p:menuitem id="addCompGrpMenu2" value="add Y" />
<p:contextMenu for="objectClassMasterData" nodeType="component" id="menuComponent">
<p:menuitem id="editComp" value="edit Y"/>
<p:menuitem id="deleteComp" value="delete Y" />
<p:menuitem id="addComp" value="add Z"/>
<p:contextMenu for="objectClassMasterData" nodeType="testObject" id="menuTestObject">
<p:menuitem id="editTestObj" value="edit Z"/>
<p:menuitem id="deleteTestObj" value="delete Z"/>
<p:menuitem id="addTestInstr" value="add A"/>
<p:contextMenu for="objectClassMasterData" nodeType="testInstruction" id="menuTestInstruction">
<p:menuitem id="editTestInstr" value="edit A" />
<p:menuitem id="deleteTestInstr" value="delet A" />

6) Example bean

public void init() {
	initiateTree("Root Node");

private void initiateTree(final String rootLabel) {
	root = new DefaultTreeNode("objectClass", rootLabel, null);
	final TreeNode node0 = new DefaultTreeNode("componentGroup", "Node 0", root);
	final TreeNode node1 = new DefaultTreeNode("componentGroup", "Node 1", root);
	final TreeNode node2 = new DefaultTreeNode("componentGroup", "Node 2", root);

	final TreeNode node00 = new DefaultTreeNode("component", "Node 0.0", node0);
	final TreeNode node01 = new DefaultTreeNode("component", "Node 0.1", node0);
	final TreeNode node10 = new DefaultTreeNode("component", "Node 1.0", node1);
	final TreeNode node11 = new DefaultTreeNode("component", "Node 1.1", node1);

	final TreeNode node000 = new DefaultTreeNode("testObject", "Node 0.0.0", node00);
	final TreeNode node001 = new DefaultTreeNode("testObject", "Node 0.0.1", node00);
	final TreeNode node010 = new DefaultTreeNode("testObject", "Node 0.1.0", node01);
	final TreeNode node100 = new DefaultTreeNode("testObject", "Node 1.0.0", node10);

	final TreeNode node1001 = new DefaultTreeNode("testInstruction", "Node", node100);

    public TreeNode getRoot() {
	return root;

ContextMenu must be placed AFTER the attachable component.

@tandraschko tandraschko added the invalid label Nov 23, 2016

I can still see the context menu and if that would have been the case context menu should not have been appear. Additionally same code is working primefaces version 5.3 :(
Anyway I have tried keeping the context menu tag after tree as well but it doesn't work.


I would suggest to please open the defect again or please let me know if you have some other solution.

tandraschko commented Nov 23, 2016 edited

Yeah, we changed that with 6.0. I can only work if it's placed after now.
If you update your sample to a complete sample with a whole xhtml and java bean and which doesn't work when the contextmenu is placed AFTER, i will reopen it.


I have update my code. Please have a look and reopen it. Thanks.


Sry but please provide a full working example for testing. Some stuff like messages or createComponentGroup is missing.



@tandraschko tandraschko reopened this Nov 24, 2016
@tandraschko tandraschko removed the invalid label Nov 24, 2016
@mertsincan mertsincan added this to the 6.1 milestone Dec 20, 2016
@mertsincan mertsincan added a commit that closed this issue Dec 20, 2016
@mertsincan mertsincan Fixed #1920 c6f31fd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment