title: Highlight selected node from managed bean in primefaces
body: <p>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:-</p>
  
  <p>In Managed Bean,</p>
  
  <pre><code>getSelectedNode().setStyleClass("ui-helper-clearfix ui-tree-node-content ui-corner-all ui-tree-selectable-node ui-state-highlight");
  </code></pre>
  
  <p>In xhtml,</p>
  
  <pre><code>&lt;p:treeNode id="privilegesTreeNode" styleClass="#{privilegesTreeBean.selectedNode.styleClass}"&gt;
                          &lt;h:outputText value="#{node}" id="lblNode" /&gt;
                      &lt;/p:treeNode&gt;
  </code></pre>
  
  <p>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>
  
  <pre><code>&lt;p:treeNode id="privilegesTreeNode" styleClass="#{privilegesTreeBean.selectedNode.styleClass ne '' ? privilegesTreeBean.selectedNode.styleClass : ''}"&gt;
                          &lt;h:outputText value="#{node}" id="lblNode" /&gt;
                      &lt;/p:treeNode&gt;
  </code></pre>
  
  <p>Can anyone help me as I'm stuck in this.</p>
  
  <p>Thanks in Advance</p>