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;
      
      @Name("treeAction")
      public class Tree
      {
       private TreeNode tree = new TreeNodeImpl();;
      
       public Tree()
       {
       TreeNodeImpl fooNode = new TreeNodeImpl();
       fooNode.setData("foo!");
      
       TreeNodeImpl barNode = new TreeNodeImpl();
       barNode.setData("bar!");
      
       TreeNodeImpl tarNode = new TreeNodeImpl();
       tarNode.setData("tar!");
      
       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;
       }
      
      
      }
      


      XHTML
      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
       "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
      
      <html xmlns="http://www.w3.org/1999/xhtml"
       xmlns:h="http://java.sun.com/jsf/html"
       xmlns:f="http://java.sun.com/jsf/core"
       xmlns:ui="http://java.sun.com/jsf/facelets"
       xmlns:a4j="http://richfaces.org/a4j"
       xmlns:rich="http://richfaces.org/rich">
      
      <head>
      </head>
      <body>
      <h3>Rich Faces Tree Test</h3>
      <h:form>
       <rich:tree value="#{treeAction.tree}" var="node">
       <rich:treeNode>
       <h:outputText value="#{node}" />
       </rich:treeNode>
      
       </rich:tree>
      </h:form>
      </body>
      </html>
      


      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.