Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

trying to get a richfaces tree to populate nodes using data from xml  RSS feed

 
Matt Kohanek
Village Idiot
Ranch Hand
Posts: 484
Java jQuery Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
edited out first question since I have it resolved

I followed the exact example from thsi site:

http://livedemo.exadel.com/richfaces-demo/richfaces/treeNodesAdaptor.jsf?tab=usage&cid=488771

It is the tree example for richfaces. However, when I try to dispaly it on my local host it just shows a blank white page. Which I assume means it is not finding any nodes to populate the tree with. if I understand the code, they are getting their nodes from /WEB-INF/src, because this is in the java code:



So I am assuming I need to replace WEB-INF/src with my own data source. I tried using an xml file that I put in the same folder as the tree.xhtnl page, so I replaced WEB-INF/src with /src.xml, but it is also showing just a white page. I feel like I am close to figuring this out, but I just need to figure out what should be put in there as the data source. Any suggestions?


edit - also, when I try to replace WEB-INF/src with other things sometimes instead of a blank page it gets an error saying:

javax.servlet.ServletException: /test/recursiveNodesTest/tree.xhtml @11,120 roots="#{fileSystemBean.sourceRoots}": Error reading 'sourceRoots' on type testContainer.FileSystemBean
 
Matt Kohanek
Village Idiot
Ranch Hand
Posts: 484
Java jQuery Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The more I mess with this the more I realize it is coming down to the exact same problem I have been trying to find an answer for for days now. I need to write the java code that will go through the xml elements and use the data from them to populate nodes. There is sample code out there for how to do this using a .properties file, and ow to do this usng modes, but I cant find any help anywhere for doing this from xml! Its getting really old, Im not sure what else to try, where else to ask for help, or how else to phrase the problem.

Maybe if someone see the source code for doing this using nodes or a .properties file..

Here is how to do it using nodes as yoru data source:



and using a .properties file as the data source:



Now from seeing how it is done in these two ways, can someone set me down the right path for doing this from xml?
 
Tim Holloway
Bartender
Posts: 18705
71
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In theory, you could just use the Apache Digester to slurp in the entire XML and build a model tree of objects and then use the RichFaces tree "generic datamodel" support to render it, but I might be hallucinating functions that I actually saw on some unrelated component.

IIRC, I showed you my (rather nasty) example of a tree I'm working with the other day, but it's pulling the data from a database.
 
Matt Kohanek
Village Idiot
Ranch Hand
Posts: 484
Java jQuery Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
well Ill try anything at this point, Ive spent a good 8 hours trying to figure this out already
 
Matt Kohanek
Village Idiot
Ranch Hand
Posts: 484
Java jQuery Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I dont think I need to use the apache digester actually, because I already have code written that uses simplexml to turn the data into a stream. Although I am not sure what form the data is in after it is turned into a stream. If someone could clear that up it would probably help me with this.

I need to follow something like this

XML -> simple XML -> java objects -> tree model

It is the "java objects" part that is giving me the trouble though.

This is my method to deserialize (or is it serialize, whichever one means to read the xml data) the xml:



So at that point, the data is stored in the "device" variable, right? Now I just need to figure out how to use that to parse that and use it in the tree right? Which is where I am having the problem, like I said, with the java objects.
 
Kavita Tipnis
Ranch Hand
Posts: 177
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Matt Kohanek wrote:I dont think I need to use the apache digester actually, because I already have code written that uses simplexml to turn the data into a stream. Although I am not sure what form the data is in after it is turned into a stream. If someone could clear that up it would probably help me with this.

I need to follow something like this

XML -> simple XML -> java objects -> tree model

It is the "java objects" part that is giving me the trouble though.

This is my method to deserialize (or is it serialize, whichever one means to read the xml data) the xml:



So at that point, the data is stored in the "device" variable, right? Now I just need to figure out how to use that to parse that and use it in the tree right? Which is where I am having the problem, like I said, with the java objects.


I have not tried this, but try putting your java objects in a collection and then let the adaptor iterate through it
 
Matt Kohanek
Village Idiot
Ranch Hand
Posts: 484
Java jQuery Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the reply, and I am actually trying to do just that but have probelms with it as well. Here is the thread I started in the java forums trying to get this resolved if your interested:

http://www.coderanch.com/t/447245/Java-General-intermediate/java/Trying-bind-data-TreeNode-attribute
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!