wood burning stoves 2.0*
The moose likes JSF and the fly likes Problem getting richfaces tree to display Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "Problem getting richfaces tree to display" Watch "Problem getting richfaces tree to display" New topic
Author

Problem getting richfaces tree to display

Matt Kohanek
Village Idiot
Ranch Hand

Joined: Apr 04, 2009
Posts: 483

FIrst off, Im not sure if this is the corect forum, if not Im sorry, please feel free to move this.

Im just doing a simple richfaces tree to get my template set up. The code is very simple:




However when i try to run this on my server I get the following error:






I am trying to find a solution online, but a search for that error returs absolutely no results, so I am havgina bit of trouble, If you know what may be the problem with this please let me know.

Thanks


True wisdom is in knowing you know nothing - Socrates
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper

Joined: Aug 26, 2006
Posts: 4968
    
    1

Could it be as simple as the fact that there is no form tag surrounding your elements? What if you wrap your tree inside a richfaces form tag?

Just a kick at the can...

-Cameron McKenzie
Matt Kohanek
Village Idiot
Ranch Hand

Joined: Apr 04, 2009
Posts: 483

Sorry, I shouldve updated this, but I did realize I was missing a form and view tag. I added them, but NOW only a blank page gets displayed when I try to run it on my local server. ANy ideas?

So the new code:



edit - I also tried it with a4j:form instead of h:form but still get a blank page.
I know it has to be some combination of the crrect tags and order of the tags but I feel like I ahve tried every variation
Matt Kohanek
Village Idiot
Ranch Hand

Joined: Apr 04, 2009
Posts: 483

I dont know if this will help, but I put this into a two column table, on the left column, to see if it would display a blank space for that cell or if the table would act as if there was nothing in the cell. It did just the latter, The left column was gone, and the stuff that I put in the right column took up the entire row.

I have no idea what this means, but hopefully someone with more experience wil?
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16158
    
  21

I'd show you my working XML, but it's dynamic and complex, and would probably just make the confusion worse.

I can't see anything wrong with your latest attempt. Try a clean rebuild and redeploy to flush out any stale artifacts.

I'd also recommend you double-check against the "show source" options on the RichFaces LiveDemo for trees, in case you do have something wrong and I'm just too blind to see it.


Customer surveys are for companies who didn't pay proper attention to begin with.
Matt Kohanek
Village Idiot
Ranch Hand

Joined: Apr 04, 2009
Posts: 483

Well, eventually mine will ned to be dynamic as well, by about June 8th actually, so if you have a chance and don't mind feel free to post some to give me some code to refer to.
Matt Kohanek
Village Idiot
Ranch Hand

Joined: Apr 04, 2009
Posts: 483

here is a part of a reply I got on the richfaces forum:

"tree could not be created declarativelly. check our samples and documentation and create proper dataModel for the tree."

So if I am interpreting this correctly this person is saying I cant define nodes in that manner? Meanign I cant just assign values statically, it must be done dynamically with managed beans or some such? The post was somewhat difficult to interpret because the poster was from Belarus
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16158
    
  21

The documentation for RichFaces was written by someone whose native language was not English. Unfortunately, I think it was one of the languages related to English, so the differences are just subtle enough to be more confusing than if they had grown up speaking Tamil.

Here's my dynamic tree code:


I told you it was ugly.

I used the RichFaces reference guide to build the model itself, but thanks to the languages issues, the resulting code is just too awful to show.
Matt Kohanek
Village Idiot
Ranch Hand

Joined: Apr 04, 2009
Posts: 483

I mentioned it another thread, but in the hopes of spreadng it around, I belive this site should set up a donations link, like the help forums at cybertechhelp.com

I donate every year because just like this site I get tons of great help.

Thanks again
Matt Kohanek
Village Idiot
Ranch Hand

Joined: Apr 04, 2009
Posts: 483

I do have this working now as intended. I am wondering about something still so if you have an answer please feel free...

Rigt now my data source is a .properties file. This data from the .properties file is used to display the tree. But Im not sure if this is going to work for my project. All the data that will populate the nodes is located on a web service, with this format:



The nodes will be populated from the name, devices, and channels elements. So Im not yet sure how to translate this to the tree. I can deserialize the data with a method I have. Is it possible to generate temporary .properties files that last for the session? Or does anyone know a better way to take the data from those three elements and use them to populate the tree nodes? FYI, I havent started looking into this at all yet, so there may be an obvious answer out there. If so please feel free to tell me to just do my research X-)
Enrico Kusnady
Greenhorn

Joined: Jul 10, 2009
Posts: 9
Hello @ Matt Kohanek,


I am a newbie here and i have an exact error like you..
which is, on the browser i get this


I want to ask you how uou solved your problem???



I need your help..

Thank you
Matt Kohanek
Village Idiot
Ranch Hand

Joined: Apr 04, 2009
Posts: 483

It was just that I did not have everything wrapped in a <form> tag just like Cameron said. IF that doesn't fix it post your code so I can see what you have
Enrico Kusnady
Greenhorn

Joined: Jul 10, 2009
Posts: 9
Hello,

First, this is my source code:


In the preview, it was like this


So when i deployed it, i should see at least the same preview on my browser.
But this is what i got from my web browser:



I didn't change anything on my faces-config.xml and web.xml.


I am using Eclipse Ganymede 3.4.1, updated JBoss Tools from Eclipse, using JBoss AS 4.2 Runtime.

You have any idea?
Matt Kohanek
Village Idiot
Ranch Hand

Joined: Apr 04, 2009
Posts: 483

Yep, even when using ui tags you still have to wrap it all in a form tags. Actually if you have multiple ui:defines you will need multiple form tags too, one inside of each ui:define tag.

Try this:



The only thing I did was add h:form tags enclosing everything inside of your ui:define tag.


Also here is one of my pages Im woking on that uses multiple ui:define tags. Notice how inside each one, the frst thing I start with is h:form:

Enrico Kusnady
Greenhorn

Joined: Jul 10, 2009
Posts: 9
Hello,

Thank you thank you thank you very much.......
Wow.... It showed something.. Welll the tree wasn't shown but at least there is no error on the webbrowser anymore.

This is the result :
[img=http://img37.imageshack.us/img37/6409/36846534.jpg]


Maybe i want to try like you.
I want to make a Java Class (Java Bean). In this Class i will make a tree.

Then on my .xhtml data, as value i will add like this #{bean.text} or something like that.

My question is: if i want to do like that, i should add a managed bean on the faces-config.xml (with the name "bean", based on #{bean.text}")

But should i also change or add some code on web.xml??


Matt Kohanek
Village Idiot
Ranch Hand

Joined: Apr 04, 2009
Posts: 483

I don't think you need to change anything on the web.xml file just for adding a bean, just in faces-config.xml like you say.

Here is my web.xml file just in case though:




and your going to have tons of fun trying to get rich:trees to work lol, I just recently finished mine that took me 3 months to get everything right...

The best place for getting answers to your tree problems is the richfaces JBoss forum:

http://www.jboss.org/index.html?module=bb&op=viewforum&f=261

Mu username is meghiddo there, so just search from some of my posts to see the many many questions I have had about them (including regarding the problem your having - you cant declare nodes declaratively or something liek that, I dont remember exactly)
Enrico Kusnady
Greenhorn

Joined: Jul 10, 2009
Posts: 9
Hello...

Wow.. After 3 months?? oh my God..

You make me scared now...

Could i see your Tree Java Code please?

Matt Kohanek
Village Idiot
Ranch Hand

Joined: Apr 04, 2009
Posts: 483

Well it involves quite a few classes, but the main two are the ProjectHolder class, which is just an Object to hold all the variables, and then a Nodes class which performs the operations to give those variables values and then load each instance of the ProjectHolder object into a List. Then I bind that list to the rich:tree.

And dont let my troubles with it scare you, I had just started learning about jsf back then and my java was very rusty. Plus the tree was just one of a great many different things I had to do, so that whole three months wasnt just for the tree. First the ProjectHolder class that just declares the variables and setters and getters for them:




And my nodes class which loads the ProjectHolder class variables with values (values taken from a web service) and then for each instance of that ProjectHolder Object it loads the ProjectHolder Object into a List:




Then I declare a managed bean in faces-config:




And last the tree itself:





If you want to see any of the other classes that are involved that you see in the code just tell me which ones, but that should give you the general idea of how I did mine. There are many different ways to do a tree though, it all depends on what you are needing. Mine was complex because the tree is generated dynamically depending on what is added and deleted from the web service. But if your making a tree that will always have the same roots and nodes that is fairly simple.
Enrico Kusnady
Greenhorn

Joined: Jul 10, 2009
Posts: 9
Hello Matt,

i just realize, my web.xml is not the same like your web.xml.

You can looked at the codes that i circled with a red color.
My web.xml didn't have that code.
Did you add that code manually or is it automatically there?





Thank you for you feedback
Matt Kohanek
Village Idiot
Ranch Hand

Joined: Apr 04, 2009
Posts: 483

My web.xml came about from me following the dev guide that is with richfaces. I couldnt tell you for sure what that does, the web.xml is still somewhat of a mystery to me
Enrico Kusnady
Greenhorn

Joined: Jul 10, 2009
Posts: 9
Well, ok thank you for your answer.

And another question.. What kind of project you had?

Because i tried to make this tree on Seam Web Project.

What bout you??

Ok, i tried already to make the implemented tree from http://livedemo.exadel.com/richfaces-demo/richfaces/tree.jsf?tab=model&cid=1445593
But it is not quite good written i think.
Because there are only Open Source, Java Source.

And i dont know if i do it right. For Example, that java source i put it in this folder, or the open Source i put it in that folder.
Hmmmm it is frustrating me....

And in this forum http://www.jboss.org/index.html?module=bb&op=main&c=27 they only answered me like this.. "Yeah.. run the sample from the beginning... it is very simple"
But they didn't really explain it one by one.... ARghhhhhh
Matt Kohanek
Village Idiot
Ranch Hand

Joined: Apr 04, 2009
Posts: 483

That is actually one of their few samples I could get working.

Your problem is probably from this line of the SimpleTreeBean.java source:

private static final String DATA_PATH = "/richfaces/tree/examples/simple-tree-data.properties";

you have to either create that Data Path, or change it there. So step one is to create a .properties file, they have it named simple-tree-data.properties, and copy and paste that long list of artists and works they have under "Open Data File". Just open that and copy and paste all that into your .properties file and save it. Now depending on where you saved it you will need to change the private static final String DATA_PATH = "/richfaces/tree/examples/simple-tree-data.properties"; line from the java code. If you saved your .properties file under the WebContent folder, then that line would simply be changed to

private static final String DATA_PATH = "/WebContent/simple-tree-data.properties";

The bottom line is, you have to create that .properties file and then in the java source code change the Data Path so it knows where to find it.

Hope that makes sense.

And yes, it is sometimes very hard to get any answers from the JBoss forums. I used a combination of this forum and that forum to get things going.
Enrico Kusnady
Greenhorn

Joined: Jul 10, 2009
Posts: 9
Hello,


i don't know how to say thank you to you.
You answer me very fast. I really really thank you once again.

Anyway, you forgot to answer my first question.
The Project where you made tree is Seam Web Project, right?
And you run that project on JBoss?? Or from TomCat?

Because my project is Seam Web Project with the Runtime JBoss AS 4.2 (Which means : it run from the Server JBoss).

Matt Kohanek
Village Idiot
Ranch Hand

Joined: Apr 04, 2009
Posts: 483

I believe the answer to your question is JavaServerFaces v1_2 project if I understand what your asking. And I use Tomcat configuration, I like it much more than JBoss.

I made a word doc with setup instructions and put all the JARs I use in a zip file for my group members to help them catch up with me when I started this project, so Ill give you the url to download that if you want to look at it. Basically I go through setting up a project from the beginning in it with screenshots. Plus there are a lot of useful JARs there if you ever need them. Just open read_me.doc to see the setup and the JARs are all in a separate folder


Heres where you can download it:

http://www.sendspace.com/file/5y8932

take a look and get back to me if you need anything else about it. I would send you my full project code to look and play with, but right now am under an NDA so I cant do that
Enrico Kusnady
Greenhorn

Joined: Jul 10, 2009
Posts: 9
Hello Matt,

i thank you once again for being very helpful to me.
I really trully appreciate it.

Well, because you already made it. You can make a tree with Richfaces, so i want to do exactly what you did when you made a RichFaces tree.
I want to do 100% the same as you.
And when i saw your web.xml, there are 4 beans ( AddAll, ProjectTreeTest, DeviceTree, Address).
But because i didn't have those beans.

I tried a "VERY SIMPLE" RichFaces tree from http://livedemo.exadel.com/richfaces-demo/richfaces/tree.jsf?tab=model&cid=1445593
But when i used your word-tutorial to make the default tree model from that live demo Website, i got another problem. ( I hate programming.. It is always about another another and another problem).


And then, i went back to my first plan which was Seam Web Project.

In this file, you could see what i did. http://www.sendspace.com/file/rad9dd

It stressed me up. I got even more nervous. Many people in the forum said that those examples are very simple
For me, it is not simple at all. I still could not make it.

It is really impossible. I started to try to make a tree with Richfaces since 2 weeks ago. And until today, i still got nothing...
Enrico Kusnady
Greenhorn

Joined: Jul 10, 2009
Posts: 9
Hello Matt,

ohhhhhhhhhhhhh.. i am so happy. You won't believe it.

I did it.... At last............
Fiuh............


What i want to do now is, i want that my children node have another children node.

But at last, i could make a tree with RichFaces tree.. ohh.. Finally..

Thank you very much for your help so far.

I found another tutorial http://technology.amis.nl/blog/4710/multi-select-in-richfaces-trees#comment-348596

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem getting richfaces tree to display