On 5/8/2010 8:38 AM, uglyhunK wrote:
> Hi,
>
> This is what I was set out to do. But stuck in the first step itself.
>
> - send a HTTP GET request to yahoo search api request using
> "qx.io.remote.Request"
> - marshal json response into a model using "qx.data.marshal.Json"
> - create a controller and bind the model to UI widget
>
> Twitter tutorial did the same thing but used JSONP request and uses
> json store. But I don't see a way I can use JSON store to send POST
> requests. Though my example is not POST, if I get this my code to work
> with GET, it can surely be used for POST as well. So, I used
> "qx.io.remote.Request" to send AJAX request and the use a marshaller
> to create the model. I'm not sure if my understanding of the qooxdoo
> databing is correct. Would appreciate is someone confirms this.
>
> Now, coming to the problem with the following code, instead of sending
> http GET requests, I see the http method as OPTIONS. Where is it going
> wrong ??? And obviously, I could not check if marshaling json response
> is working.
>
> // code snippet
> var list = new qx.ui.form.List();
> this.getRoot().add(list);
>
> var resp = null;
> var req = new
> qx.io.remote.Request("http://search.yahooapis.com/ImageSearchService/V1/imageSearch",
>
> "GET", "application/json");
> req.setParameter("appid", "YahooDemo");
> req.setParameter("query", "Sachin Tendulkar");
> req.setParameter("output", "json");
>
> req.addListener("completed", function(e) {
> resp = e.content;
> });
>
> req.send();
>
> // create model from the json response
> var json = new qx.data.marshal.Json(null);
> json.toClass(resp, true);
> var model = json.toModel(resp);
>
> // create controller
> var controller = new qx.data.controller.List(model, list);
> controller.setLabelPath("obj.ResultSet.totalResultsAvailable");
>
> Cheers
>
Oops, it's a cross-domain issue. I have to use jsonp to use the
webservice. But I still would like to know if json marshing part of the
code is right or wrong.
Cheers
------------------------------------------------------------------------------
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel