javascript - how to implement JSNI in GWT - Stack Overflow

I have experience in GWT but know nothing about JSNI or Javascript . i am searching for few days for JS

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(@.jsni.client.HelloJSNI::testJSNI(IFI));

    }-*/;
}

will i be able to see "hello JSNI "? Thanks

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(@.jsni.client.HelloJSNI::testJSNI(IFI));

    }-*/;
}

will i be able to see "hello JSNI "? Thanks

Share Improve this question edited Mar 11, 2012 at 20:50 user1226162 asked Mar 11, 2012 at 20:14 user1226162user1226162 2,0429 gold badges29 silver badges43 bronze badges 1
  • Could you please first understand using the Java "Native" keyword without even considering GWT. – Blessed Geek Commented Mar 12, 2012 at 0:26
Add a ment  | 

1 Answer 1

Reset to default 2

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.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745641613a4637726.html

相关推荐

  • javascript - how to implement JSNI in GWT - Stack Overflow

    I have experience in GWT but know nothing about JSNI or Javascript . i am searching for few days for JS

    22天前
    50

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信