Como chamar a função java GWT do Javascrip
É possível chamar métodos Java (GWT) de Javascript? Também não está claro na documentação. Todas as amostras aquihttp: //code.google.com/intl/ru/webtoolkit/doc/latest/DevGuideCodingBasicsJSNI.htm demonstrar a chamada de funções java a partir de funções JSNI (não JS
UPDATE 1
Aqui está um código Java:
public class Test_GoogleWeb_JSNI_02 implements EntryPoint {
/**
* This is the entry point method.
*/
public void onModuleLoad() {
}
public static void Callee() {
Window.alert("Callee");
}
}
Aqui estão exemplos de botões de chamadas em html:
<input type='button' value='Call' onclick='Test02()'>
E aqui estão algumas funções que tentei e que não foram trabalhadas:
<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
O seguinte funcionou.
Preparação Java:
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();
}
Existe uma maneira melhor