5 Replies Latest reply on Apr 4, 2007 12:46 PM by Nick Belaevski

    Tree & treeNode

    Evgeny Morozov Newbie

      There is a problem with tree component. I have done all the same on the documentations with Library, Artist and so on. But there is nothing on my web-page: no tree, no exception - just nothing, but on the html-code there is a tree without data and on the debug-mode Library is not invoked.
      Could comebody help me with it?

        • 1. Re: Tree & treeNode
          Adrian Iacob Newbie

          Give more details.
          As far as I understood you create a tree like connections between your classes using the interface TreeNode. Their example has a start managed bean that implements TreeNode that load everything from a text file.

          It worked for me

          • 2. Re: Tree & treeNode
            Evgeny Morozov Newbie

             

            "adrian.iacob" wrote:
            Give more details.
            As far as I understood you create a tree like connections between your classes using the interface TreeNode. Their example has a start managed bean that implements TreeNode that load everything from a text file.

            It worked for me

            I just tried to more simple example - without text file. So I have this classes:
            @Stateful
            @Name("tmanager")
            public class Treemanager implements TreemanagerInterface
            {
             private Treeroot root;
            
             /* (non-Javadoc)
             * @see TreemanagerInterface#destroy()
             */
             @Remove
             @Destroy
             public void destroy()
             {
             }
            
             /* (non-Javadoc)
             * @see TreemanagerInterface#getData()
             */
             public Object getData()
             {
             if (root == null)
             {
             init();
             }
             return root;
             }
            
             private void init()
             {
             this.root = new Treeroot();
             this.root.setType("root");
             this.root.setName("root");
             this.root.setParent(null);
            
             for (int i = 0; i < 4; i++)
             {
             Treeroot item = new Treeroot();
             item.setType("root");
             item.setParent(this.root);
             item.setId(i);
             this.root.addChild(i, item);
             item.setType("item");
             item.setName("item" + i);
             }
             }
            }


            import org.richfaces.component.TreeNode;
            
            public class Treeroot implements TreeNode
            {
             private static final long serialVersionUID = 1L;
             private int id;
             private Map<Object, TreeNode> childs;
             private TreeNode parent;
             private String name;
             private String type;
            
             public Treeroot()
             {
             childs = new HashMap<Object, TreeNode>();
             }
            
             public Treeroot(String name)
             {
             this();
             this.name = name;
             }
            
             public Treeroot(String name, TreeNode parent)
             {
             this(name);
             setParent(parent);
             }
            
             public void addChild(Object id, TreeNode child)
             {
             getChilds().put(id, child);
             }
            
             public int getChildsSize()
             {
             return getChilds().size();
             }
            
             private Map<Object, TreeNode> getChilds()
             {
             return this.childs;
             }
            
             public TreeNode getChild(Object id)
             {
             return (TreeNode)getChilds().get(id);
             }
            
             public Iterator getChildren()
             {
             return getChilds().entrySet().iterator();
             }
            
             public Object getData()
             {
            
             return this;
             }
            
             public TreeNode getParent()
             {
             return this.parent;
             }
            
             public boolean isLeaf()
             {
             return getChilds().isEmpty();
             }
            
             public void removeChild(Object id)
             {
             TreeNode tmp = getChild(id);
             tmp.setParent(null);
             getChilds().remove(id);
             }
            
             public void setData(Object arg0)
             {
             }
            
             public void setParent(TreeNode parent)
             {
             this.parent = parent;
             }
            
             public String getName()
             {
             return name;
             }
            
             public void setName(String name)
             {
             this.name = name;
             }
            
             public String toString()
             {
             return name;
             }
            
             public String getType()
             {
             return name;
             }
            
             public void setType(String type)
             {
             this.type = type;
             }
            
             public int getId()
             {
             return id;
             }
            
             public void setId(int id)
             {
             this.id = id;
             }
            }


            And there is my xhtml page:
            <rich:tree switchType="client" width="300" height="150" value="#{tmanager.data}" var="item" nodeFace="test">
             <rich:treeNode type="test">
             <h:outputText value="#{item.name}" />
             </rich:treeNode>
             </rich:tree>


            But now when I'm trying to deploy I get next exceptions:

            21:48:36,637 WARN [ServiceController] Problem starting service jboss.j2ee:service=EJB3,module=mytree2.jar
            java.lang.NoClassDefFoundError: org/richfaces/component/TreeNode
             at java.lang.Class.getDeclaredMethods0(Native Method)
             at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
             at java.lang.Class.getDeclaredMethods(Unknown Source)
             at org.jboss.injection.InjectionUtil.processMethodAnnotations(InjectionUtil.java:96)
             at org.jboss.injection.InjectionUtil.processAnnotations(InjectionUtil.java:172)
             at org.jboss.ejb3.EJBContainer.processMetadata(EJBContainer.java:270)
            ...


            And

            21:48:43,617 ERROR [[/mytree2]] Exception sending context initialized event to listener instance of class org.jboss.seam.servlet.SeamListener
            java.lang.RuntimeException: Could not create Component: tmanager
             at org.jboss.seam.init.Initialization.addComponent(Initialization.java:865)
             at org.jboss.seam.init.Initialization.installComponents(Initialization.java:796)
             at org.jboss.seam.init.Initialization.init(Initialization.java:503)
             at org.jboss.seam.servlet.SeamListener.contextInitialized(SeamListener.java:33)
             at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3763)
             at org.apache.catalina.core.StandardContext.start(StandardContext.java:4211)
             at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:759)
            ...


            It seems that I didn't do something. But I'm reading seam_reference now and I didn't find answer for my question yet. It'll be very good if you could help me.

            • 3. Re: Tree & treeNode
              Dustin Norlander Apprentice

              I believe its a classloading problem. you probably need to set usejbossclassloader=true (search the forums for instructions)

              • 4. Re: Tree & treeNode
                Evgeny Morozov Newbie

                Have done... but problem wasn't solved.
                Yesterday I have created tree with nodes, it works fine, but it seems there is some bugs...
                I think problem is in the other place - I just started to read j2ee tutorial and I don't understand all features of components, tags and so on. So I'm going to continue read tutorial.

                Thanks a lot for your answers.