6 Replies Latest reply on Nov 13, 2008 10:11 PM by Nick Belaevski

    Tree Problem

    Steven Wright Newbie

      Can someone please post a simple example of how to implement a simple rich faces tree? I have dug through this forum for the last two hours and I cannot find what I am looking for. Here is my current code:

      Backing Class

      import org.jboss.seam.annotations.Name;
      import org.richfaces.model.TreeNode;
      import org.richfaces.model.TreeNodeImpl;
      public class Tree
       private TreeNode tree = new TreeNodeImpl();;
       public Tree()
       TreeNodeImpl fooNode = new TreeNodeImpl();
       TreeNodeImpl barNode = new TreeNodeImpl();
       TreeNodeImpl tarNode = new TreeNodeImpl();
       tree.addChild("foo", fooNode);
       fooNode.addChild("bar", barNode);
       barNode.addChild("tar", tarNode);
       public TreeNode getTree()
       return tree;
       public void setTree(TreeNode tree)
       this.tree = tree;

      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
      <html xmlns="http://www.w3.org/1999/xhtml"
      <h3>Rich Faces Tree Test</h3>
       <rich:tree value="#{treeAction.tree}" var="node">
       <h:outputText value="#{node}" />

      Here is the error that I get when I view the output in a browser.

      org.richfaces.model.TreeNodeImpl cannot be cast to org.richfaces.model.TreeNode

      I am at my wits end to be honest. Any rational advice would be appreciated. I am not exactly new to JSF and Rich Faces I have been working with it for about a year.