[Dev] calling javascript methods in an external js file from gwt JSNI native mthods
Hi all, I am trying to do $Subject. When the JavaScript method is in the of html file itself I can call the method from module load as a native method using JSN [1]I. But when i refer to the js file from html page [2] and put the method in to the js file i get the following gwt error[3]. Has anyone ever attempted anything similar and achieved it successfully? [1] in java class public static native void gwtjsPlumbDemo() /*-{ $wnd.gwtjsplumbdemo(); }-*/; [2] in gwtjsplumbdemo.js file function gwtjsplumbdemo() { alert("Success!!!"); } in html [2] [115:32:19.737 [ERROR] [gwtjsplumb] Unable to load module entry point class com.wso2.codenvy.client.GWTJsplumb (see associated exception for details) com.google.gwt.core.client.JavaScriptException: (TypeError) @com.wso2.codenvy.client.GWTJsplumb::gwtjsPlumbDemo()([]): Object doesn't support property or method 'gwtjsplumbdemo' at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:249) at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136) at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:576) at com.google.gwt.dev.shell.ModuleSpace.invokeNativeVoid(ModuleSpace.java:304) at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeVoid(JavaScriptHost.java:107) at com.wso2.codenvy.client.GWTJsplumb.gwtjsPlumbDemo(GWTJsplumb.java) at com.wso2.codenvy.client.GWTJsplumb.onModuleLoad(GWTJsplumb.java:43) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at com.google.gwt.dev.shell.ModuleSpace.onLoad(ModuleSpace.java:411) at com.google.gwt.dev.shell.OophmSessionHandler.loadModule(OophmSessionHandler.java:200) at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:526) at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:364) at java.lang.Thread.run(Unknown Source) thanks and regards Awanthika Senarath Software Engineer, WSO2 Inc. Mobile: +94717681791 ___ Dev mailing list Dev@wso2.org http://wso2.org/cgi-bin/mailman/listinfo/dev
Re: [Dev] calling javascript methods in an external js file from gwt JSNI native mthods
Can you try the option available at [1] where it uses ScriptResources for ClientBundle instead of tags. [1] https://plus.google.com/u/0/+RayCromwell/posts/g3TmFeao8kK Thanks, Sohani Sohani Weerasinghe Software Engineer WSO2, Inc: http://wso2.com Mobile : +94 716439774 Blog :http://christinetechtips.blogspot.com/ Twitter : https://twitter.com/sohanichristine On Wed, Sep 3, 2014 at 4:41 PM, Awanthika Senarathwrote: > Hi all, > > I am trying to do $Subject. > > When the JavaScript method is in the of html file itself I can > call the method from module load as a native method using JSN [1]I. But > when i refer to the js file from html page [2] and put the method in to > the js file i get the following gwt error[3]. Has anyone ever attempted > anything similar and achieved it successfully? > > [1] in java class > public static native void gwtjsPlumbDemo() /*-{ > > $wnd.gwtjsplumbdemo(); > > }-*/; > > > [2] in gwtjsplumbdemo.js file > function gwtjsplumbdemo() { > alert("Success!!!"); > } > in html >