5 Replies Latest reply on Sep 22, 2007 12:27 PM by Maksim Kaszynski

    How to get data from treeNode

    Matthias Graehn Newbie

      Hi,

      I tried the following code (a modified version of treeNodesAdaptor demo) and it works great. to set the current node selected I pass the treeNodeAdaptor via f:attribute and do set the Data in the backing bean.

      <rich:tree switchType="client" ajaxSubmitSelection="true">
       <rich:treeNodesAdaptor id="project"
       nodes="#{contentEditTreeBean.projects}" var="project">
       <rich:treeNode icon="#{project.icon}" iconLeaf="#{project.icon}">
       <a4j:commandLink reRender="dynamicNavigation"
       actionListener="#{contentEditTreeBean.nodeClicked}"
       value="#{project.name}">
       <f:attribute name="content" value="#{project}" />
       </a4j:commandLink>
      
       </rich:treeNode>
       <rich:treeNodesAdaptor id="packets" var="packet"
       nodes="#{project.packages}">
       <rich:treeNode icon="#{packet.icon}" iconLeaf="#{packet.icon}" >
       <a4j:commandLink actionListener="#{contentEditTreeBean.nodeClicked}"
       value="#{packet.name}">
       <f:attribute name="content" value="#{packet}" />
       </a4j:commandLink>
       </rich:treeNode>
      ...
      


      public void nodeClicked(ActionEvent event){
       Object obj = event.getComponent().getAttributes().get("content");
       currentNode = obj;
       System.out.println(obj.getClass());
      }
      


      Is there a better way to get the data of the selected node? Maybe via treeNode treeNodeAdaptor...?

      Greets
      Matt