I have experience in GWT but know nothing about JSNI or Javascript . i am searching for few days for JSNI now but i am not able to understand how to implement JSNI in my GWT project.
where and how i will add a javascript file in my GWT project, where i will write my javascript?
and then i want to call a javascript method from java/GWT
Here is a simple example of how to code a JSNI method that puts up a JavaScript alert dialog:
public static native void alert(String msg) /*-{
$wnd.alert(msg);
}-*/;
but where will i add this code in my GWT project
i hvae just created a new project "HelloJSNI" and in my class HelloJSNI.java , i added this code , am i doing write ?
public void onModuleLoad() {
alert("call from java to Javascript");
}
public void testJSNI(int amt, float interestRate,
int term){
Window.alert("call from javascript to java");
}
public static native void alert(String msg) /*-{
// $wnd.alert(msg);
$wnd.testJSNI=
$entry(@com.jsni.client.HelloJSNI::testJSNI(IFI));
}-*/;
}
will i be able to see "hello JSNI "? Thanks
The first and best place to learn about JSNI is this article.
If you have any more specific questions after reading that article, please ask here on SO.