When i run that it prints out the deviceId so the String x is definitely holding the value I am needing it to. But now I need to figure out how to add those values to a list. There could be anywhere from 0-100 values. I tried something like this:
But there is a mismatch between String and list there, because device.getDeviceId returns a String. Is there a quick method to do this parsing? I mean Ive learned the basic things most students learn in a java class for converting from say int to String, but we did not really eal with lists. Can anyone give me a tip on this, Im sure it is something easy
edit - in the mean time I am going to look at some more java list tutorials
True wisdom is in knowing you know nothing - Socrates
Maybe you can help clear up what I should do here, I know I am close but not quite there.
I have called data froma web service, and used simplexml to parse that data. Then I set this inputStream equal to deviceColelction.
So now deviceColelction holds this input stream and when I tried to print out the value of deviceId from deviceCOllection I got the value I thought I would get.
The code to do so looked like:
So now for every device in my deviceCollection I am able to get the value of DeviceId. Remember these values are originally stored in xml form like this:
Now it took me DAYS to just get it to this point. But I am now able to iterate through these values, and then assign them to a String value. Now the final step is to use the values that this returns to populate the branches of a rifchfaces tree. My only options for this value are collection(list), array or map, because those are the only data types that a recursive tree node adaptor accepts, according to the people who wrote the richfaces code.
So I need to somehow iterate through my deviceCollection (which is storing that xml as an input stream), and have it pull out whatever is between the <deviceId> tag, which I seemingly have the code for up to this point. Then I need to add this value to one of those three data types, and add a getter for it.
I know I have to be close, because if Im no Im going to go postal. But it seems I am... Like I said, I can go through my deviceColelction after it has taken the data from the web service, and get it to return the value I am looking for. Now I just need to add this value to one of those three data types, so I can make a getter for it and bind that to the recursive tree node on my jsf page.
What would be your advice here?
edit - and unfortunately it is not an option to change device.getDeviceId to something other than String value. It would just ruin too much other code that is working already, essentially i would have to trash a good month of work
eh forget it, I have been at this for too long and made too little progress. I can get a tree to show up using a .properties file as my data source, but that is the best I have been able to do.
It sucks, and it wont look good, but I am just gonna have to tell this company that this is out of the range on my abilities.
I will get this project as far as I can using a .properties file, and that is just gonna have to be it. What the hell else can I do, maybe I have chosen the wrong career path
If that's all you want to do -- and in your other thread, I asked if that's what you wanted to do, and the conversation that started up with the other guy seemed to indicate you wanted something much more complex -- then it's very very easy. Create the new list before the loop, and then inside the loop, use "add()" to add each one to the list.
Well, although that did work and I now have a list ids that is holding the values, when I bind it to my tree it just comes up as a blank page.
Thanks for the help.
I hate to quit but at some point you have to ask yourself, "do I keep working on this one little thing and risk having nothing to show by the deadline, or move on so I at least have a few other things to show?"
I decided to make one last post to try and get this solved. If someone is up for a challeneg here it is:
Dont even click the link if you dont want to spend some time trying to solve this, it will just be a waste of your time because I highly doubt someone will be able to just read through the post and see what my problem is. Youll probably have to copy and try some of the code yourself to solve this one. Just a warning so no one wastes their time
thought some of you who have seen me working on thsi same problem for two weeks might like to know it turns out my source code is all working fine, it has something to do with the JARs...
someone on the rich forums finally got tired of seeing all my possts Im sure, because he asked me to upload my source code so he could check it himself...
here is what he posted:
I've removed throws (wrapped all in try/catch for now) and successfully launched the application on Tomcat 6 and JBoss 5.0.1.GA (removed jsf-api/jsf-impl and stax-* jars from the project before deploying to JBoss). I see one leaf tree - as in the source XML file.
Of course I tried his fix, but I still have problems (big surprise eh)
Here is my reply to his post:
I messed things up for myself even more now it would seem.
How do you start the server without the jsf api and jsf impl jars, every time I try to I get this log:
SEVERE: Exception starting filter richfaces
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
Caused by: java.lang.ClassNotFoundException: javax.faces.FacesException
... 28 more
And then when I add those jars back in the server starts with no errors, but then when trying to launch the tree I get
edit - I created a new project where I removed all the redundancies, and used server supplied implementation rather than mojarra (jsf-api and jsf-impl), but I get errors starting the server. But as soon as I put jsf-api and impl into my lib folder the server starts fine. So Im being told those jars are causing my problems, yet I cant get ther server started without them!
Im not sure what your referring to by application server. This setting up of JARs s totally new territory to me, it was only by some miracle that I got things working in the first place. Here is the only way in which I can get my server to start without errors, by having these libraries:
JRE System Library - this libraray just shows up without me specifying it
Mojarra (is implementation) jsf-api
RFJars (I created this one) commons-beanutils
RichFaces (another I created) richfaces-api
WebApp (jars show up in here after I add libraries to WEB-INF/lib) jsf-api
plus two free jars that are under no library heading commons-codec-1.3
So I have doubles of commons-beanutils, commons-collections, and commons-logging; and triples of commons-digester. Before i tried the fix I got from the rich forum I only had one copy each of jsf-api and jsf-impl in the mojarra library, but now the only way to get my server to start correctly is by also placing these two jars in WEB-INF/lib, creating duplicates of them. However if Im understanding I should not need those two at all. But if that is o, why does my serve get errors every time I try to start without them (unless there are no projects deployed to the server)
I should give the steps I take when creating a new project to I think.
New->dynamic web project->
target runtime is jboss5.0
configuration is facelet 1.0 project
then when asked to choose between server suplied implementation or one of my choosing, I choose my own - mojarra (which includes jsf-api and jsf-impl jars only)
then Im also prompted to choose other libraries and I choose
-apache commons (commons-beanutils, commons-collections, commons-digester, commons-logging)
-RFJARS which is one I created (commons-beanutils, commons-collections, commons-digester, commons-logging, jsf-facelets, jstl-1.2)
-Richfaces, another library I created - (richfaces-api, richfaces-impl, richfaces-ui)
then hit finish. after that I still needed some other jars so I manually added them to the build path. they are (commons-codec, and yet another commons-digester)
and finally I put some jars in my web-inf/lib folder (simple-xml, stax-1.2.0, and stax-api-1.0.1) Ive recently also had to add jsf-api and jsf-impl to this folder because after I tried to remove the mojarra libraray upon advice from the jboss forums, now the only way to get my server started correctly is to have those to jars in this folder
I think these lines from my web.xml file may be the problm:
As soon as I removed those though my libraries started going crazy and changing positions and eclipse wont let me do anything... we shall see...