2 Replies Latest reply on Jun 23, 2009 6:00 PM by busysatish

    UITree walk does not pass

    pdpantages

      Hello Forum,

      I am using:
      Seam 2.0.1.GA
      Richfaces 3.1.4.GA

      I am trying to use UITree.walk() with DataVistitor to expand a tree
      from a selected root, when the operator clicks a context menu.

      Everything seems to work as expected except that
      the argument parameter (second parm) is always null when my process() method is called.

      I am trying to pass the UITree as the "argument" so that I can call
      tree.queueNodeExpand( treeRowKey ) for each of the nodes.

      The first parm is always properly set to an instance of treeRowKey, but
      the second parm ("argument") is alwya null.

      Am I missing something obvious?

      Any hints will be greatly appreciated...

      ( I can resort to setting the UITree in my Expander instance,
      so this is not a show stopper at this point... )

      Thanks, PdP

      My xhtml


      <rich:tree switchType="ajax" stateAdvisor="#{subnetTreeImpl.alarmTreeStateAdvisor}" binding="#{subnetTreeImpl.alarmTree}" id="alarmTree" >
      
       <rich:recursiveTreeNodesAdaptor roots="#{treeData}" var="node" nodes="#{node.children}" >
      
       <rich:treeNode rendered="#{node.nodeType == node.nodeTypeSubnet}" iconLeaf="/img/subnet16.png" icon="/img/subnet16.png">
      
       <s:link value="#{node.description}" styleClass="#{node.styleClass}"
       action="#{activeAlarmsImpl.setSubnetFilter}" >
       <f:param name="id" value="#{node.id}"/>
       </s:link>
      
       <rich:contextMenu disableDefaultMenu="true" event="oncontextmenu" attached="true" submitMode="ajax">
      
       <rich:menuItem value="Expand"
       rerender="subnetTreePanel"
       action="#{subnetTreeImpl.expandSubTree}">
       <s:conversationId/>
       </rich:menuItem>
      
       <rich:menuItem value="Collapse"
       rerender="subnetTreePanel"
       action="#{subnetTreeImpl.collapseSubTree}">
       <s:conversationId/>
       </rich:menuItem>
      
       </rich:contextMenu>
      
       </rich:treeNode>
      
       </rich:recursiveTreeNodesAdaptor>
      
      </rich:tree>
      


      Relevant parts of my backing bean
      private final static TreeRange RANGE_UNCONSTRAINED = new TreeRange()
       {
       public boolean processChildren(TreeRowKey rowKey) {
       return true;
       }
      
       public boolean processNode(TreeRowKey rowKey) {
       return true;
       }
       };
      
      private static class Expander implements DataVisitor
      {
       public void process(javax.faces.context.FacesContext faces,java.lang.Object obj1, java.lang.Object obj2)
       {
       if ( obj1 != null ) {
       TreeRowKey treeRowKey = (TreeRowKey) obj1;
       System.out.println ("DataVisitor rowKey" + treeRowKey );
       }
      
       if ( obj2 != null )
       System.out.println ("DataVisitor obj2 " + obj2.getClass() );
       else
       System.out.println ("DataVisitor obj2 " + obj2);
       }
      }
      
      public String expandSubTree()
      {
       try {
       Object key = alarmTree.getRowKey();
       TreeRowKey treeRowKey = (TreeRowKey) key;
       alarmTree.walkModel (javax.faces.context.FacesContext.getCurrentInstance(), new Expander(), RANGE_UNCONSTRAINED, treeRowKey, alarmTree );
       }
       catch (Exception e) {
       e.printStackTrace();
       }
       return null;
      }