Now I have another always about the JSNI. here you have my code:
public native int editBlog(String data) /*-{
var xhr_object = null;
if($wnd.XMLHttpRequest) {// Firefox
xhr_object = new XMLHttpRequest();
}
else if($wnd.ActiveXObject) {// Internet Explorer
xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
}
else { // XMLHttpRequest non supporté par le navigateur
$wnd.alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest...");
return;
}
var URL = this.@com.rest.gwt.blogger.client.service.EditBlogCommand::url;
xhr_object.open("PUT", URL, true);
var code;
xhr_object.onreadystatechange = function() {
code = xhr_object.readyState;
if(code == 4) {
var response = xhr_object.responseText;
$wnd.alert(response);
this.@com.rest.gwt.blogger.client.service.EditBlogCommand::cb();
if(xhr_object.status == 200) {
$wnd.alert("Status code = 200");
this.@com.rest.gwt.blogger.client.service.EditBlogCommand::callBack(Ljava/lang/String;)(response);
}
}
}
data.@java.lang.String::toString();
xhr_object.send(data);
$wnd.alert(code);
return xhr_object.code;
}-*/;
I this method I send correctly the datas to the server and I receive response from it. But I want to work with the server response in other method in my application, the callBack method. But the problem is, the line
this.@com.rest.gwt.blogger.client.service.EditBlogCommand::callBack(Ljava/lang/String;)(response);
is not executed by the compiler. The $wnd.alert("Status code = 200"); instruction but not the line after it.
Pehaps It's not a good syntaxe or I must use other think befor. I have also read the chapter8 about Building JSNI components but I have note see the response of my problem.
Notice: I know that I can use the RequestBuilder with Http GET method, and a parameter to say the server that my method is normally other instead the GET method. On the server side, I can use this technic but I want to know all possibilities that GWT gives the developpers to communicate with server. At finaly I can make the comparaison between the all possibilities and conclude.