1 Reply Latest reply on Jun 17, 2007 4:27 PM by Bram Biesbrouck

    Only top-level rich:treeNodes commit their commandLink-actio

    Bram Biesbrouck Newbie

      Hi all,

      I'm experiencing weird behaviour with my rich:Tree component.

      Only the commandLink-actions in the toplevel treeNodes work.
      When I expand a node, the commandLink-actions of it's children just cause a reload of the page; no backing-bean action is called.

      Here's my view-tier-code:

      <rich:tree value="#{fileSystemManager.spaceTreeModel}" var="spaceMemberInode" nodeFace="#{spaceMemberInode.isContainerInode}" switchType="server">
      
       <rich:treeNode type="true">
       <h:commandLink action="#{fileSystemManager.changeSelectedSpaceMember(spaceMemberInode.fileSystemEntity)}"
       value="#{spaceMemberInode.fileSystemEntity}" />
      
       </rich:treeNode>
      
       <rich:treeNode type="false" />
      
      </rich:tree>
      


      Note that everything works fine when I use switchType="client" (ajax doesn't work either).
      Also note that I'm using the Seam-enhanced actionMethods with parameters.

      Any ideas?

        • 1. Re: Only top-level rich:treeNodes commit their commandLink-a
          Bram Biesbrouck Newbie

          Oh, and here's the backing-bean:

          @Name("fileSystemTreeNode")
          public class FileSystemTreeNode implements TreeNode, Serializable
          {
           protected Inode inode;
           protected Map<Inode, FileSystemTreeNode> cachedChildren;
          
           public FileSystemTreeNode()
           {
           }
           public FileSystemTreeNode(Inode inode)
           {
           this.inode = inode;
           this.cachedChildren = null;
          
           reloadChildren();
           }
          
           public boolean equals(Object o)
           {
           if ( this == o ) return true;
           if ( o == null || getClass() != o.getClass() ) return false;
          
           final FileSystemTreeNode node = (FileSystemTreeNode) o;
          
           //this could go wrong, type-wise
           try {
           Inode inode = (Inode)node.getData();
           /*
           * For two nodes to be equals, their inode must be the same
           */
           return inode.getId()==this.inode.getId();
           }
           catch (Exception e) {
           return false;
           }
           }
          
           public void addChild(Object entityInstance, TreeNode child)
           {
           //TODO: not implemented
           }
           public void removeChild(Object entityInstance)
           {
           //TODO: not implemented
           }
           public Object getData()
           {
           return inode;
           }
           public void setData(Object data)
           {
           this.inode = (Inode)data;
           }
           public TreeNode getParent()
           {
           Inode parent = this.inode.getParentInode();
           if (parent!=null) {
           return new FileSystemTreeNode(this.inode.getParentInode());
           }
           else {
           return null;
           }
           }
           public void setParent(TreeNode parent)
           {
           //TODO: not implemented
           }
           public TreeNode getChild(Object obj)
           {
           if (cachedChildren==null) {
           reloadChildren();
           }
          
           return cachedChildren.get((Inode)obj);
           }
           public Iterator getChildren()
           {
           if (cachedChildren==null) {
           reloadChildren();
           }
          
           return cachedChildren.entrySet().iterator();
           }
           public boolean isLeaf()
           {
           if (DirectoryInode.class.isAssignableFrom(this.inode.getClass())) {
           if (cachedChildren==null) {
           reloadChildren();
           }
          
           return cachedChildren.isEmpty();
           }
           //a FileInode is always a leaf
           else {
           return true;
           }
           }
          
           private void reloadChildren()
           {
           //init the cachedChildren here, this way, we won't do this again if not necessary
           this.cachedChildren = new HashMap<Inode, FileSystemTreeNode>();
          
           //check if we are a directory
           if (DirectoryInode.class.isAssignableFrom(this.inode.getClass())) {
           DirectoryInode directory = (DirectoryInode)this.inode;
           List<Inode> directoryChildren = directory.getImmediateChildrenInodes();
          
           for (Inode child : directoryChildren) {
           cachedChildren.put(child, new FileSystemTreeNode(child));
           }
           }
           else {
           return;
           }
           }
          }