I have a doGet(String url, final AsyncCallback callback) method for retrieving a JSON from a server with REST function, but i don't know how to call it in the onModuleLoad(). The code is:
public void doGet(String url, final AsyncCallback<JavaScriptObject> callback) {
RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, url);
try {
builder.sendRequest(null, new RequestCallback() {
public void onError(Request request, Throwable caught) {
callback.onFailure(caught);
}
public void onResponseReceived(Request request, Response response) {
if(response.getStatusCode() == STATUS_CODE_OK) {
try {
callback.onSuccess(JsonUtils.safeEval(response.getText()));
} catch(IllegalArgumentException iax) {
callback.onFailure(iax);
}
}
else {
callback.onFailure(new Exception("Bad return code..."));
}
}
});
} catch(RequestException e) {
callback.onFailure(e);
}
}
I know this is a stupid question (I'm a beginner) but how can i call doGet? For example:
doGet("http://192.168.1.10:8080/ProvaRpi/raspberry/sample/artisti", what here?);
I need the AsyncCallback because i want to show the JSON from the database in another page or in a TextBox. Every code improvement is welcome! Thank you!