我正在使用带有contextMenu的树,这里是代码:
<p:contextMenu id="campaignPlaneTreeContextMenu" for="campaignPlanetree" >
<p:menuitem value="New Camapign" disabled="#{projectCampaignManagementMB.campaignOptionsFlag}" />
<p:menuitem value="Assign" disabled="#{projectCampaignManagementMB.FSTOptions}" />
<p:menuitem value="Copy campaign" disabled="#{projectCampaignManagementMB.FSTOptions}"/>
<p:menuitem value="Paste Campaign" disabled="#{projectCampaignManagementMB.pasteOptionCampaignFlag}"/>
<p:menuitem value="Delete" disabled="#{projectCampaignManagementMB.FSTOptions}" />
<p:menuitem value="Import Tests" disabled="#{projectCampaignManagementMB.campaignOptionsFlag}" />
</p:contextMenu>
<p:tree id="campaignPlanetree"
value="#{projectCampaignManagementMB.root}" var="node"
selectionMode="single"
selection="#{projectCampaignManagementMB.selectedNode}"
dynamic="true">
<p:ajax event="select" listener="#{projectCampaignManagementMB.onCampaignPlaneNodeSelect}" update=":campaignForm:addCampaignBtn :campaignForm:renameCampaignBtn :campaignForm:importCampaignBtn :campaignForm:deleteCampaignBtn :campaignForm:importCampaignDlg :campaignForm:campaignPlaneTreeContextMenu" />
<p:treeNode value="#{node}">
<h:outputText value="#{node}" />
</p:treeNode>
.....
ManagedBean:
if(selectedNode.getData() instanceof Campaign){// when a user select a tree node the contextmenu item are disabled and enabled
setCampaignOptionsFlag(false);
....
}
没有禁用属性,每件事都很好,但添加后,上下文菜单会立即消失。
答案 0 :(得分:2)
我发现当你将光标放在每个节点的箭头上时,我的意思是在所选树节点的左边,上下文菜单不会立即消失。
但是在最后一个树级别(叶子)你不会看到箭头,因为节点不可扩展 所以它肯定是一个主要的错误