File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Trying to bind data to a TreeNode attribute using data read from a web service with simple xml Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Trying to bind data to a TreeNode attribute using data read from a web service with simple xml" Watch "Trying to bind data to a TreeNode attribute using data read from a web service with simple xml" New topic
Author

Trying to bind data to a TreeNode attribute using data read from a web service with simple xml

Matt Kohanek
Village Idiot
Ranch Hand

Joined: Apr 04, 2009
Posts: 483

This is basically what I need to do:

1) Call Web service and get the xml
2) Use simpleXML to parse XML into objects
3) loop through objects and add to TreeNode data; attribute.

I have a bunch of loose code that does much of this, but it is missing something and Im having trouble filling in the gaps.

So I have this class which is how I call the web service and get the data:



I also have a Device class:



and a device Collection class:



Then I have my Temp class, which I am trying to use to bind the data from the DeviceColelction to TreeNode data;



I think I have my temp class fixed now. But now my last problem is using deviceCollection to build my tree. I thought deviceCollection would be considered a list so I could do deviceCollection.get() but appaently thats not the case


True wisdom is in knowing you know nothing - Socrates
Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

Only looked at this _very_ quickly, so hopefully others comment, but I I don't think your DeviceCollection class can be considered a List, it's a wrapper around a List. So you need to get the list out of your wrapper class first before performing a get() on it.


Cheers, Martijn - Blog,
Twitter, PCGen, Ikasan, My The Well-Grounded Java Developer book!,
My start-up.
Matt Kohanek
Village Idiot
Ranch Hand

Joined: Apr 04, 2009
Posts: 483

eh, Im not even sure I need it to act like a list...

All I really know is that I have a page that has an xml schema that is very simple, one root and two child nodes that changes depending on the user (can be multiple root nodes with the two child nodes)

I am needing to bind the values of the root and two child nodes to something, which I can then call in my richfaces tree to populate the branches.

Ive posted so many topics and looked at so many tutorials I am just overloaded with un needed knowledge that doesnt pertain to my problem, btu just gets in the way of my figuring out how to solve it

If I werent on a deadline I would just give up on this at this point, but Im between a rock and a hard place
Matt Kohanek
Village Idiot
Ranch Hand

Joined: Apr 04, 2009
Posts: 483

I mean there has to be some way to say (programmatically):

1 - look at this xml schema
2 - take whatever the text node value is for <deviceId> and set it equal to String device;

It seems so simple, but I just cant seem to do it!!
Kavita Tipnis
Ranch Hand

Joined: Sep 21, 2008
Posts: 177
Matt Kohanek wrote:eh, Im not even sure I need it to act like a list...

All I really know is that I have a page that has an xml schema that is very simple, one root and two child nodes that changes depending on the user (can be multiple root nodes with the two child nodes)

I am needing to bind the values of the root and two child nodes to something, which I can then call in my richfaces tree to populate the branches.

Ive posted so many topics and looked at so many tutorials I am just overloaded with un needed knowledge that doesnt pertain to my problem, btu just gets in the way of my figuring out how to solve it

If I werent on a deadline I would just give up on this at this point, but Im between a rock and a hard place


You are almost there, but your DeviceCollection should return a list and not a collection because I think it JSF RI will not downcast from a Collection to any subclass.
Alternately, you already parse out your XML so just create a class which holds data for each user, based on your description above I am just laying out a basic
structure


in your jsf then for the tree nodes , you can iterate through list of xmlnodes and each node can get the value
xmlNodes[0].rootNode[0].deviceId or something similar

Not sure if it helps but that's what came in up my head while sipping coffee !


P.S any bartender: for some odd reason the forum did not show my reply, I am resubmitting this reply again
Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

Kavita Tipnis wrote:
P.S any bartender: for some odd reason the forum did not show my reply, I am resubmitting this reply again


We've been experiencing some difficulties yes, rest assured a number of staff are looking into a fix.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Trying to bind data to a TreeNode attribute using data read from a web service with simple xml
 
Similar Threads
XmlTreeDataBuilder Class inputsource question.
rich:tree working now... all the work has finally paid off - THANKS
Need to call a method to populate my list, then have that list bound to rich tree
How can I use println to display the value of data when I node.setData((TreeNode) deviceCollection..
Trying to figure out why Im getting "cannot be resolved" error