How can I update the children after a node in a tree?

Hello world.
I am updating a subtree programmatically using a bean managed as data source.
I can find all the topics are about the use of your and JUCtrlHierNodeBinding.updateValuesFromRows.
Now, I need to find a way to directly update the nodes without any line. What should I do?

Here is the code:

Tags:
                                <af:tree id="tframe" initiallyExpanded="true"
                                         selectionListener="#{backingBeanScope.systemDataFrameBB.onSelectNode}" var="n"
                                         binding="#{backingBeanScope.systemDataFrameBB.tframe}"
                                         value="#{systemDataFrameMB.treeData}" expandAllEnabled="true"
                                         rowSelection="single" fetchSize="-1" contentDelivery="immediate"
                                         immediate="true" summary="summary">
                                    <f:facet name="nodeStamp">
                                                  <af:group>
                                                  <af:outputText value="#{n.is_system?'[SYSTEM]':''}" />
                                                  <af:outputText value="#{n.is_use?'':'[X]'}" />
                                                                 <af:outputText value="#{n.data_frame_name}"/>
                                                  </af:group>
                                    </f:facet>
                                </af:tree>
(systemDataFrameMB) bean managed:
     private ChildPropertyTreeModel treeData;
     public ChildPropertyTreeModel getTreeData() throws SQLException
     {
          if (this.treeData == null)
          {
               AuthAMImpl authAM = this.getAppModule();
               List<DataFrameNode> subTrees = authAM.getDataFrameTrees();    // load with JDBC and POJO

               DataFrameNode root = new DataFrameNode();      // insert all sub-trees into a new tree
               root.setData_frame_id(0);
               root.setData_frame_name("[ROOT]");
               root.setParent_data_frame_id(Integer.MIN_VALUE);
               root.setIs_system(true);
               root.setIs_use(true);
               if (subTrees != null && subTrees.size() > 0)
               {
                    root.setChildren(subTrees);
                    for (DataFrameNode n : subTrees)
                         n.setParent(root);
               }
               this.treeData = new ChildPropertyTreeModel(root, "children");      // I guess this is the simplest way to show hierachical data...
          }
          return this.treeData;
     }
model:
public class DataFrameNode
{
     private int data_frame_id;
     private String data_frame_name;
     private int parent_data_frame_id;
     private boolean is_use;
     private boolean is_system;

     private DataFrameNode parent;
     private List<DataFrameNode> children;

        // getters/setters are omitted....
}
support bean (systemDataFrameBB):
        // edit event handler
     public void onEditResult(DialogEvent de)
     {
          String name = (String)this.getItName().getValue();
          boolean isUse = this.getSbcIsUse().isSelected();
          SystemDataFrameMB dfMB = (SystemDataFrameMB)JSFUtils.resolveExpression("#{systemDataFrameMB}");

          try
          {
               node.setData_frame_name(name);
               node.setIs_use(isUse);
               dfMB.updateNode(node);                   // persist changes, this method will change all the children's 'is_use' field to FALSE when isUse == FALSE
               AdfFacesContext.getCurrentInstance().addPartialTarget(this.getTframe());      // refresh the tree, only the edited node will be updated, but I want the tree to update the whole sub-tree to reflect the change on all its children
          }
          catch (Exception e)
          {
                        // omitted...
          }
        }

Yes, you must use JUCtrlHierNodeBinding to update entire tree.

Tags: Java

Similar Questions

Maybe you are looking for