Is it possible to call Java (GWT) methods from Javascript? It is also unclear from documentation. All samples here http://code.google.com/intl/ru/webtoolkit/doc/latest/DevGuideCodingBasicsJSNI.html demonstrate calling java functions from JSNI (not JS) functions.
UPDATE 1
Here is a Java code:
public class Test_GoogleWeb_JSNI_02 implements EntryPoint {
/**
* This is the entry point method.
*/
public void onModuleLoad() {
}
public static void Callee() {
Window.alert("Callee");
}
}
Here is caller button samples in html:
<input type='button' value='Call' onclick='Test02()'>
And here are some functions I tried and which were not worked:
<script type="text/javascript">
function Test01() {
@com.inthemoon.tests.client.Test_GoogleWeb_JSNI_02::Callee()();
}
function Test02() {
com.inthemoon.tests.client.Test_GoogleWeb_JSNI_02::Callee()();
}
</script>
UPDATE 2
The following worked.
Java preparation:
public void onModuleLoad() {
Prepare();
}
public static native void Prepare() /*-{
$doc.calleeRunner = @com.inthemoon.tests.client.Test_GoogleWeb_JSNI_02::Callee();
}-*/;
public static void Callee() {
Window.alert("Callee");
}
Caller:
function Test03() {
document.calleeRunner();
}
Is there a better way?