Reputation: 7940
I have following code:
public static void show(String value){
Window.alert("From Java");
invokeMethod(); //Does not get called
}
public static native void invokeMethod() /*-{
alert("From JSNI");
}-*/;
I want to call a JSNI method from Java method, however invokeMethod()
never gets called...
I could not find much use cases for calling JSNI method from Java.
Why isn't above code working?
Upvotes: 1
Views: 406
Reputation: 954
First of all, as Colin Alworth said, you need to change your code to $wnd.alert("From JSNI"); If you want to call another JS function apart from alert(), you should write the body of your function in your html page. You'll find all information needed here
So your code should look like this:
public static void show(String value){
Window.alert("From Java");
invokeMethod();
}
public static native void invokeMethod() /*-{
$wnd.alert("From JSNI"); //Added "$wnd."
}-*/;
Upvotes: 1