I have never used Restlet
, but it seems that it relays in GWT RequestBuilder
. In consequence, since RequestBuilder
supports CORS, gwt-restlet should do.
You can use any GWT ajax technique (RPC, RF or RequestBuilder) with CORS without problem. Think that GWT have the same restrictions of any other html/javascript application, and CORS will work if the browser is compatible with CORS (IE9 is not) and the server is correctly configured.
Said that, I encourage you to give a try to gwtquery which gives you an easy way to deal with ajax. Normally, I use gwtquery ajax to consume 3party services because of its syntax and simplicity.
The goal of gQuery syntax is that you can take almost jQuery examples and port them to without so much effort.
This is a simple example:
ajax(Ajax.createSettings()
.setUrl("miservice.php")
.setDataType("json") // txt, json, jsonp, xml
.setType("get") // post, get
.setData($$("param1: 1, param2: 2")) // parameters in json, $$() creates json from string
.setSuccess(new Function(){ // callback to be run if the request succeeds
public void f() {
// The response when dataType=json is a javascript object (Properties)
Properties json = getDataProperties();
}
})
);
In the case of JSON (or XML) I use gQuery databinding to map the response with java objects.
For instance:
interface Site extends JsonBuilder {
long getId();
String getUrl();
Site setId(long id);
Site setUrl(String url);
}
...
Site site = GWT.create(Site.class);
site.load(getDataProperties();
Window.alert(site.getUrl();
...