• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

How to work with t:tree component

 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a class called TreeBean() like this,

public class TreeBean
{

private DefaultTreeModel tree;

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,

<t:tree id="tree" value="#{treeBean.tree}"
styleClass="tree"
nodeClass="treenode"
selectedNodeClass="treenodeSelected"
expandRoot="true">
</t:tree>

but when i run this xhtml file, the tree is not displaying.
Only empty page is displaying.

How to dispaly tree.

Regards,
Vinutha.
 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
vinutha
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi rajani

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

So, how to resolve this.

Thanks,
Vinutha.
 
Ranch Hand
Posts: 190
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
vinutha
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I had this code in my faces-config.xml.

<application>
<variable-resolver>
org.springframework.web.jsf.DelegatingVariableResolver
</variable-resolver>
<view-handler>com.sun.facelets.FaceletViewHandler</view-handler>
<locale-config>
<default-locale>en_US</default-locale>
<supported-locale>en_US</supported-locale>
<supported-locale>en</supported-locale>
</locale-config>
</application>

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.

Thanks,
Vinutha.
 
James Clinton
Ranch Hand
Posts: 190
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If your using facelets you need to declare the components in a tomahawk.xml file. At least you do for jboss.

My advice would be to get this workinf with JSPs, if that works you know your classpath etc is fine.
 
rajani varma
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi vinutha,

We are using tomahawk-1.1.3 and not using facelets.

And I am using <t:tree2> component.

Cheers
Rajani
 
rajani varma
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
But the code you posted with <t:tree> also worked fine for me. May be because of the tomahawk-1.1.3 version..........

And in my faces-config.xml, I didn't include anything regarding the tree, except the treeBean.
 
vinutha
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi rajani,

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.......

Thanks,
Vinutha.
 
rajani varma
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi vinutha,

I am using jsf pages, not xhtml.

so my jsf page is



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.

And here is my backing bean...




and the faces-config.xml has



Hope this helps you...

-Rajani
 
vinutha
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Rajani,

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....

Vinutha.
 
rajani varma
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Its ok vinutha. you are welcome.

-Rajani.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi vinutha,

I had the same problem to view my tree in a xhtml page.
The solution is described in the wiki myfaces :

http://wiki.apache.org/myfaces/Use_Facelets_with_Tomahawk

You must :

- Add a context param for the taglib tomahawk
- Create the tld for tomahack

Olivier
 
vinutha
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi olivier,

Thanks for your reply.
I will try this.

Thanks,
Vinutha
 
You learn how to close your eyes and tell yourself "this just isn't really happening to me." Tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic