Note that there are some explanatory texts on larger screens.

plurals
  1. POGWT and REST (jax-rs)
    primarykey
    data
    text
    <p>I have a project where you can ask for ressources that are served by jax-rs in the json format. Everything works properly in the browser when I query the rest URL the json appears. </p> <p>Now I want my GWT project to request those ressources and process them and show them in my interface. The simplest way I found to do so is using a request builder and an overlay. Code is lower. The problem is, it seems when the code is running it never goes into the actual RequestCallback(). The status string is never changed. I thought it could be a SOP so I added the but still doesnt work. Any ideal?</p> <pre><code>package com.workoutcell.client; //import com.google.gwt.core.client.JavaScriptObject; import com.google.gwt.core.client.JsArray; import com.google.gwt.http.client.*; import com.google.gwt.http.client.Request; import com.google.gwt.http.client.RequestBuilder; import com.google.gwt.http.client.RequestCallback; import com.google.gwt.http.client.RequestException; import com.google.gwt.http.client.Response; /** * * @author */ public class RestToInfoSession{ String queryReturn = null; JsArray&lt;InfoJSO&gt; arrayOfInfo = null; String host = "http://localhost:8080/mysite"; String restModule = "/calendar/getinfo"; String id = null; String year = null; String month = null; String status = "Not Initialized"; public RestToInfoSession(String id, String year, String month){ this.id =id; this.year = year; this.month = month; String url = host + restModule + "/"+this.id + "/"+this.year + "/"+this.month; RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, url); try { status = "Initialized at Url " + builder.getUrl(); Request request = builder.sendRequest(null, new RequestCallback() { public void onError(Request request, Throwable exception) { // Couldn't connect to server (could be timeout, SOP violation, etc.) status = "Error on connecting to Server"; } public void onResponseReceived(Request request, Response response) { if (200 == response.getStatusCode()) { // arrayOfInfo = jsonToJsArray(response.getText()); status = "JSON has been Fetched. Result is:" + response.getText(); } else if(0 == response.getStatusCode()) { status = "Error is 0"; } else { status = "Error in JSON Request:" + response.getStatusCode(); //response.getStatusText(); } } }); } catch (RequestException ex) { status = "Error in Request Builder Startup"; } } //get an jso object in array private final native JsArray&lt;InfoJSO&gt; jsonToJsArray(String json) /*-{ return eval(json); }-*/; public JsArray&lt;InfoJSO&gt; getInfoArray (){ return arrayOfInfo; } } </code></pre> <p>UPDATE: My problem is the same as <a href="https://stackoverflow.com/questions/3059527/referring-to-a-non-final-variable-data-inside-an-inner-class">Referring to a non-final variable data inside an inner class</a> .I wasnt aware of asynchronous calls working mechanism. I still dont know how to pass my response.getText() to update a label that isnt part of my RestToInfoSession class....any ideas?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload