5 Replies Latest reply on May 21, 2007 12:22 PM by Eric Ray

    Rich:tree (not displayed)

    Jan Blankenhorn Newbie

      Hey, after trying a long day to get the Rich:tree component to work I have to ask you to get some input of what i might doing wrong.

      I tried to use the example Code and build my own application on it.

      Here is my JSP:

      rich:tree style="width:300px" value="#{treeBean.data}" var="item" nodeFace="#{item.type}">
       <rich:treeNode type="root">
       <h:outputText value="#{item.type}" />
       </rich:treeNode>
       </rich:tree>


      Here is my backing Bean

      package bocis.adowx.backingBeans;
      
      
      import java.io.Serializable;
      import java.util.HashMap;
      import java.util.Iterator;
      import java.util.Map;
      
      import org.richfaces.component.TreeNode;
      
      import bocis.adowx.basic.ADOwxBaseBean;
      import bocis.adowx.tree.ADOwxTreeGroup;
      import bocis.adowx.tree.ADOwxTreeModel;
      import bocis.adowx.tree.IADOwxTreeNode;
      
      
      public class ADOwxTreeBean extends ADOwxBaseBean implements TreeNode, Serializable {
      
       private static final long serialVersionUID = -1410719824643866404L;
      
       private Map<Object, TreeNode> models = null;
      
       private Object state1;
      
       private Object state2;
      
       public ADOwxTreeBean()
       {
       initData();
       }
      
       private Map<Object, TreeNode> getModels() {
       if (this.models == null) {
       initData();
       }
       return this.models;
       }
      
       public void addNode(IADOwxTreeNode node) {
       addChild(Long.toString(node.getId()),(TreeNode) node);
       ((TreeNode)node).setParent(this);
       }
      
       public void addChild(Object identifier, TreeNode child) {
       getModels().put(identifier, child);
       }
      
       public TreeNode getChild(Object id) {
       return (TreeNode) getModels().get(id);
       }
      
       public Iterator getChildren() {
       return getModels().entrySet().iterator();
       }
      
       public Object getData() {
       return this;
       }
      
       public TreeNode getParent() {
       return null;
       }
      
       public boolean isLeaf() {
       return getModels().isEmpty();
       }
      
       public void removeChild(Object id) {
       getModels().remove(id);
       }
      
       public void setData(Object data) {
       }
      
       public void setParent(TreeNode parent) {
       }
      
       public String getType() {
       return "root";
       }
      
       private long nextId = 0;
      
       private long getNextId() {
       return nextId++;
       }
      
       private void initData() {
      
       models = new HashMap();
      
       ADOwxTreeGroup group1 = new ADOwxTreeGroup(0);
       group1.setName("Fritz");
       addChild(Long.toString(group1.getId()), group1);
       }
      
       public Object getState1() {
       return state1;
       }
      
       public void setState1(Object state1) {
       this.state1 = state1;
       }
      
       public Object getState2() {
       return state2;
       }
      
       public void setState2(Object state2) {
       this.state2 = state2;
       }
      }


      and here is another TreeNode (the intention of this is to represent a folder)

      package bocis.adowx.tree;
      
      import java.util.HashMap;
      import java.util.Iterator;
      import java.util.Map;
      
      import org.richfaces.component.TreeNode;
      
      import bocis.adowx.basic.IADOwxID;
      
      
      public class ADOwxTreeGroup implements TreeNode,IADOwxTreeNode{
      
       /*private static final long serialVersionUID = 6514596192023597908L;
       private long id;
       private Map songs = new HashMap();
       private String title;
       private Integer year;
       private Artist artist;*/
      
       private static final long serialVersionUID = 5406170156133072186L;
      
       private long id;
       private Map models = new HashMap();
       private TreeNode parent;
       private String name;
      
       public ADOwxTreeGroup(long id)
       {
       this.id = id;
       }
      
       public void addModel(ADOwxTreeModel model)
       {
       addChild(Long.toString(model.getId()), model);
       model.setParent(this);
      
       }
      
       public void addChild(Object identifier, TreeNode child) {
       models.put(identifier, child);
       }
      
       public TreeNode getChild(Object arg0) {
       return (TreeNode) models.get(id);
       }
      
       public Iterator getChildren() {
       return models.entrySet().iterator();
       }
      
       public Object getData() {
       return this;
       }
      
       public TreeNode getParent() {
       // TODO Verweis auf Parent Objekt einbinden
       return parent;
       }
      
       public boolean isLeaf() {
       return models.isEmpty();
       }
      
       public void removeChild(Object id) {
       models.remove(id);
       }
      
       public void setData(Object arg0) {
       }
      
       public void setParent(TreeNode parent) {
       this.parent = parent;
       }
      
      
       public long getId()
       {
       return id;
       }
      
       public String getType() {
       return "group";
       }
      
       public void setId(long id) {
       this.id = id;
       }
       public String getName()
       {
       return this.name;
       }
       public void setName(String name)
       {
       this.name = name;
       }
      
      }



      I don't get a error in JSF, but if i use Firebug with Firefox i get this error:

      this.elements.contentTd has no properties