There is this $entry method that we can use in GWT to allow external javascript to execute java methods. You can see the explanations in their documentation https://developers.google.com/web-toolkit/doc/latest/DevGuideCodingBasicsJSNI?hl=fr#calling
However, the example there is only with static methods. I'm trying to write it for a non-static method and when I try to call it, I get an exception :
java.lang.ClassCastException: Cannot cast com.google.gwt.core.client.JavaScriptObject$ to mypackage.MyModule
Here is my code :
public native void setRefreshModuleCallback() /*-{
$wnd.refreshModule = $entry(function() {
this.@mypackage.MyModule::refreshModuleJava();
alert('test');
});
}-*/;
public void refreshModuleJava() {
logger.log(Level.WARNING, "REFRESH");
}
What I find very funny is that alert is called, I see the result in the browser, but the call just before is not performed.
Do you know if it's actually possible to do such thing ?