2 Replies Latest reply on Jul 12, 2009 6:01 PM by malejpavouk

    Programmatic tree

    malejpavouk

      Hello...
      I am new to JSF and richfaces (myfaces, facelets), and I am trying to create a tree programatically, but nothing renders...I thing that the solution must be simple, but not for me...thanks

      public HtmlTree getCategoryTree(){
      
       Application app = FacesContext.getCurrentInstance().getApplication();
       UIViewRoot root = FacesContext.getCurrentInstance().getViewRoot();
       HtmlTree tree = (HtmlTree) app.createComponent(HtmlTree.COMPONENT_TYPE);
       tree.setId(root.createUniqueId());
       tree.setRendered(true);
       tree.setSwitchType("server");
      
      
      
       HtmlTreeNode node = (HtmlTreeNode) app.createComponent(HtmlTreeNode.COMPONENT_TYPE);
       tree.getChildren().add(node);
       node.setId(root.createUniqueId());
       node.setRendered(true);
      
      
       HtmlOutputText text = (HtmlOutputText) app.createComponent(HtmlOutputText.COMPONENT_TYPE);
       node.getChildren().add(text);
       text.setId(root.createUniqueId());
       text.setRendered(true);
       text.setValue("some text");
      
      
       return tree;
      
       }
       <h:form>
       <rich:tree binding="#{categoryBean.categoryTree}">
       </rich:tree>
       </h:form>