public DefaultTreeModel getTree() { return tree; } public void setTree(DefaultTreeModel tree) { this.tree = tree; } public TreeBean() {
DefaultMutableTreeNode root = new DefaultMutableTreeNode("XY"); DefaultMutableTreeNode a = new DefaultMutableTreeNode("A"); root.insert(a); DefaultMutableTreeNode b = new DefaultMutableTreeNode("B"); root.insert(b); DefaultMutableTreeNode c = new DefaultMutableTreeNode("C"); root.insert(c);
DefaultMutableTreeNode node = new DefaultMutableTreeNode("a1"); a.insert(node); node = new DefaultMutableTreeNode("a2 "); a.insert(node); node = new DefaultMutableTreeNode("b "); b.insert(node);
a = node; node = new DefaultMutableTreeNode("x1"); a.insert(node); node = new DefaultMutableTreeNode("x2"); a.insert(node); tree = new DefaultTreeModel(root); } }
I have a xhtml file, where i have defined tree component like this,
Hi Vinutha, Hope you got the solution for working with <t:tree> For me it is working fine. I used the same code which you posted. For the first time, I forgot to inlcude the bean in faces-config.xml and it gave me error message. And after adding in faces-config, it is working fine.
Still i am facing same problem with <t:tree> component. Can you tell me which version of tomahawk library you are using. B'coz i am using tomahawk-1.1.2. In one project, as i told you earlier nothing is displaying. Only emplty page is displaying. and in another project, an Exception is giving like this. java.lang.NullPointerException org.apache.myfaces.custom.tree.HtmlTree.addToModelListeners
Are you using facelets? As I have had this white screen of death before too.
If so you might have forgot to put your faces 'view resolver' config in the faces-config.xml
Personally, if your new to JSF, I would forget about facelets for the time being and use sitemesh. All the apache examples are based on pure JSPs and it makes life so much easier when learning IMHO.
James [ January 11, 2007: Message edited by: James Clinton ]
when i delete this code and deployed my application, its not giving any exception now. but nothing is displaying in output, ie. tree is not displaying. only empty page is displaying.
Can you post your .xhtml page and managed bean code...... Because, i am not getting anything in my page when i deploy my application. Only static text is displaying but not tree.......
As you can see, I am using the two taglibs. If I remove the taglib with prefix="f", I am getting some exception in the page like ajaxViewRoot exception. And if I remove the taglib with prefix="h", then there is no <h:form>, so I am unable to expand the tree nodes and getting javascript error like object is null. I dont know whether <t:tree> component can be used in xhtml or not.
Thanks for your reply. your code helped me lot............ I was using .xhtml file before. I dont know why it dint work with .xhtml. now, i am using jsp. Its working fine now....... Thanks once again....