I have the following code in a GWT class:
private native JavaScriptObject getRequest() /*-{
var request = ...;
request.onOpen = function(response) {
this.@com.mdarveau.fnp.client.Client::onOpen(Lcom/mdarveau/fnp/client/Response;)(response);
};
return request;
}-*/;
void onOpen( Response response ) {
Window.alert( "Got response " + response );
}
However, when the function associated with request.onOpen is called, the “this variable” is not replaced with a reference to the compiled GWT class. Using chrome javascript console and debugger I see that it looks like a reference to the request object.
Any idea why? I also have jquery loaded, could there be a conflict?
Got it: you need to get a reference to
thisin the native code and then use it in thefunctionblock:and then