0 Replies Latest reply on Apr 13, 2015 8:13 AM by vata2999

    rich:changeExpandListener does not apply to children




      I created a rich tree with changeExpandListener. it runs only at root level of my tree and does not apply to children that are being added by the listener dynamically .

      what should I do ?


      here is my code


      <rich:tree id="programTree"
                      value="#{programTreeList.treeNode}" var="_item">
                      <rich:changeExpandListener type="com.test.ui.TreeNodeXpander"/>              
                      <rich:treeNode >
                          <h:outputText value="#{_item.programName}" />


      public class TreeNodeXpander implements NodeExpandedListener
          public void processExpansion(NodeExpandedEvent nodeExpandedEvent) throws AbortProcessingException
              Object source = nodeExpandedEvent.getSource();
              if (source instanceof HtmlTree)
                  HtmlTree tree = (HtmlTree) source;          
                  Object rowKey = tree.getRowKey();
                  TreeNode modelTreeNode = tree.getModelTreeNode(rowKey);
                  Program rowData = (Program) tree.getRowData(rowKey);
                  List<Program> list = fetchChildren(rowData, modelTreeNode);
                  if (CollectionUtil.isNotEmpty(list))
                      for (Program program : list)
                          TreeNodeImpl<Program> tp = new TreeNodeImpl<Program>();
                          modelTreeNode.addChild(program.getId(), tp);//won't expand 


      PS : I am trying to create a partial(lazy) loading tree.