05-27-2012 04:29 AM
Hi. I am making an OS7 app using Java. I am very new to Java and need guidance on how to get my app to work.
Here's how my app should work.
1. User enters some input and presses a button (know this)
2. Input is passed to and appended to url (not sure)
Basically, I need to make calls to a web service at a URL http://www.whatever.com/dosomething/userinput. This URL spits out json. Then I need to take the json
3. Need to parse reponse and put it into a simple list
Do any of you have sample code on how to make calls to 3rd party web services that spit out json and put the data into a list?
4. If user clicks item in list, details of the item are displayed on different screen(not sure)
Any help greatly appreciated.
05-27-2012 07:28 AM
I recommend that you split this processing up into three separate functions:
a) Obtaining the data from the Server - create a class that is supplied the URL, connects to the Server and supplies the byte array that contains the requested data. Networking interaction like this can be quite complicated, as evidenced by the number of Threads that discuss it on this forum. I recommend you look at ConnectionFactory to do this, though in OS 7.0 you have some more sophisticated networking classes you can use. Unfortunately I have not looked at these so I can't advise on their use.
Type network in the Search box and review one of the networking videos to understand some of the complexities.
b) Json parse this byte array. This is pretty straight forward, this KB article should help:
c) Convert this Object to a UI. This is probably the most complicated part, as I suspect you will find the approach rather primitive. You will most likely be creaking a ListField, so look for samples of this. It is a little bit tricky to get your head round first time, but work on it.