Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jsf-2/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/loops/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jsf 2 突出显示primefaces中托管bean中的选定节点_Jsf 2_Primefaces - Fatal编程技术网

Jsf 2 突出显示primefaces中托管bean中的选定节点

Jsf 2 突出显示primefaces中托管bean中的选定节点,jsf-2,primefaces,Jsf 2,Primefaces,我有一个要求,我必须突出显示树中新添加的节点的一些不同的颜色。我正在使用JSF2和Primefaces树组件。我正在尝试这样的事情:- 在托管Bean中 getSelectedNode().setStyleClass("ui-helper-clearfix ui-tree-node-content ui-corner-all ui-tree-selectable-node ui-state-highlight"); 在xhtml中 <p:treeNode id="privilegesTr

我有一个要求,我必须突出显示树中新添加的节点的一些不同的颜色。我正在使用JSF2和Primefaces树组件。我正在尝试这样的事情:-

在托管Bean中

getSelectedNode().setStyleClass("ui-helper-clearfix ui-tree-node-content ui-corner-all ui-tree-selectable-node ui-state-highlight");
在xhtml中

<p:treeNode id="privilegesTreeNode" styleClass="#{privilegesTreeBean.selectedNode.styleClass}">
                        <h:outputText value="#{node}" id="lblNode" />
                    </p:treeNode>

但此css应用于所有节点..而不是所选节点..然后我想到可能在某些条件下填充,我尝试了以下方法:-

<p:treeNode id="privilegesTreeNode" styleClass="#{privilegesTreeBean.selectedNode.styleClass ne '' ? privilegesTreeBean.selectedNode.styleClass : ''}">
                        <h:outputText value="#{node}" id="lblNode" />
                    </p:treeNode>

有人能帮我吗,我被困在这里了


提前谢谢你对这种情况的想法对我来说很好

<h:outputText style="#{node.name == 'NEW NODE' ? 'background-color: yellow;' : 'background-color: none;'}" value="#{node}" />

@KBProdigy如果我必须进行多次检查怎么办?i、 e.在上面的回答中,如果根据“node.name”的值,节点可以显示为3种不同的颜色(红色、黄色和绿色),那么我该怎么做(可能调用javascript调用来执行检查并突出显示节点??