Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to highlight a primefaces tree node from backing bean
    text
    copied!<p>I am working with primefaces tree component. There is a context menu for the tree (add a node, edit node, delete node). After performing some operation, I need to refresh the tree and then highlight the node added or edited.</p> <p>This is my code.</p> <h1>index.xhtml</h1> <p></p> <pre><code> &lt;p:treeNode&gt; &lt;h:outputText value="#{node}" /&gt; &lt;/p:treeNode&gt; &lt;/p:tree&gt; &lt;p:contextMenu for="pTree" id="cmenu"&gt; &lt;p:menuitem value="Add topic as child" update="pTree, cmenu" actionListener="#{treeBean.addChildNode}" /&gt; &lt;p:menuitem value="Add topic Below" update="pTree, cmenu" actionListener="#{treeBean.addTopicBelow}" /&gt; &lt;p:menuitem value="Delete Topic" update="pTree, cmenu" actionListener="#{treeBean.deleteNode}" /&gt; &lt;/p:contextMenu&gt; </code></pre> <h1>treeBean.java</h1> <p>public class TreeBean implements Serializable {</p> <pre><code>private TreeNode root; public TreeBean() { root = new DefaultTreeNode("Root", null); // GET the root nodes first L0 List&lt;TracPojo&gt; rootNodes = SearchDao.getRootNodes111(); Iterator it = rootNodes.iterator(); while (it.hasNext()) { TracPojo t1 = (TracPojo) it.next(); String tid = t1.getTopicID(); TreeNode node1 = new DefaultTreeNode(t1, root); } } public TreeNode getRoot() { return root; } public void addChildNode(ActionEvent actionEvent) { List record = NewSearchDao.getRecord(selectedNode); Iterator it = record.iterator(); while (it.hasNext()) { Object[] record1 = (Object[]) it.next(); setParentID_dlg((String) record1[0]); setSortIndex((Integer) record1[2]); } } public void saveChilddNode() { System.out.println("Save as Child Node ........"); } </code></pre> <p>}</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload