I have a requirement that I have to highlight a newly added node in the tree to some different color. I’m using JSF2 and Primefaces tree component. I’m trying something like this:-
In Managed Bean,
getSelectedNode().setStyleClass("ui-helper-clearfix ui-tree-node-content ui-corner-all ui-tree-selectable-node ui-state-highlight");
In xhtml,
<p:treeNode id="privilegesTreeNode" styleClass="#{privilegesTreeBean.selectedNode.styleClass}">
<h:outputText value="#{node}" id="lblNode" />
</p:treeNode>
But this css is applied on all nodes..not the selected node..then I thought of may be filling on some condition, I tried this:-
<p:treeNode id="privilegesTreeNode" styleClass="#{privilegesTreeBean.selectedNode.styleClass ne '' ? privilegesTreeBean.selectedNode.styleClass : ''}">
<h:outputText value="#{node}" id="lblNode" />
</p:treeNode>
Can anyone help me as I’m stuck in this.
Thanks in Advance
Your idea with the condition works fine for me, e.g.