1 Reply Latest reply on May 8, 2008 5:30 AM by alberto Gori

    rich:tree: expand a node

    alberto Gori Novice

      The poor documentation make it very hard to do a simple operation like programatically expand a node in the tree.

      This is my code:

      TreeNode<Auto> node = findNode(bean.getAutoTreeNode(), auto);
      List<Integer> ids = new ArrayList<Integer>();
      ids.add(node.getData().hashCode());
      while (node != null) {
       node = node.getParent();
       if (node != null && node.getData() != null) {
       ids.add(node.getData().hashCode());
       }
      }
      Collections.reverse(ids);
      ListRowKey<Integer> rowKey = new ListRowKey<Integer>(ids); TreeState state = (TreeState) tree.getComponentState(); state.expandNode(tree, rowKey);
      


      Thos throws this exception in the row where I am call expandNode:
      09:50:03,366 ERROR [STDERR] java.lang.ClassCastException: java.lang.Integer cannot be cast to org.richfaces.model.StackingTreeMode
      l$Key
      09:50:03,366 ERROR [STDERR] at org.richfaces.model.StackingTreeModel.doSetupKey(StackingTreeModel.java:137)
      09:50:03,366 ERROR [STDERR] at org.richfaces.model.StackingTreeModel.setupKey(StackingTreeModel.java:175)
      09:50:03,366 ERROR [STDERR] at org.richfaces.model.StackingTreeModel.walk(StackingTreeModel.java:357)
      09:50:03,366 ERROR [STDERR] at org.richfaces.model.StackingTreeModel.walkModel(StackingTreeModel.java:455)
      09:50:03,366 ERROR [STDERR] at org.richfaces.component.UITree.walkModel(UITree.java:420)
      09:50:03,366 ERROR [STDERR] at org.richfaces.component.state.TreeState.visitNodes(TreeState.java:211)
      09:50:03,366 ERROR [STDERR] at org.richfaces.component.state.TreeState.expandNode(TreeState.java:273)
      09:50:03,366 ERROR [STDERR] at com.sia.shell.creditagricole.TreeBean.openTree(TreeBean.java:73)
      09:50:03,366 ERROR [STDERR] at com.sia.shell.creditagricole.TreeBean.setTree(TreeBean.java:32)


        • 1. Re: rich:tree: expand a node
          alberto Gori Novice

          It was because I was invoking expandNode just before rendering instead of application phase.

          Why it is not pemitted to do it just before rendering? I't non-sense because sometimes you want to open your tree after you have built it. If you are in another page you can't have an handle of the tree in the application phase so you can't open your tree programatically.

          And state.setSelected(rowKey); doesn't work!

          Because of bugs, no documentation etc... this still is not a good component, I have to say.