On Thursday, June 2, 2016 at 11:11:18 AM UTC+2, Andrew Ferguson wrote:
>
> Hi,
>
> Firstly I must say that I am not a GWT or Java developer. I have come 
> across GWT because a tool I need to incorporate into a JavaScript project 
> has been written in GWT, and I need to figure out how to link the two 
> projects together.
>
> From looking at the documentation I see that JSNI is probably what I need. 
> From the docs I have successfully created a test function inside the GWT 
> project that can be called from the external JS project. However, as soon 
> as I try to add parameters to pass data into the GWT project from the 
> external JS, the GWT project no longer compiles.
>
> My code with no parameters that compiles successfully:
>     public static int example_func() {
>       return 123;
>     }
>
>     public static native void exportStaticMethod() /*-{
>        $wnd.js_funct_equiv = 
> $entry(@com.lushprojects.circuitjs1.client.CirSim::example_func());
>     }-*/;
>
> My code with parameters that does not compile:
>     public static int example_func(int myNum) {
>       return myNum;
>     }
>
>     public static native void exportStaticMethod() /*-{
>        $wnd.js_funct_equiv(IFI) = 
> $entry(@com.lushprojects.circuitjs1.client.CirSim::example_func(IFI));
>     }-*/;
>
> Additionally, I need to be able to call an external JavaScript function 
> from the GWT project's code, and despite looking at the documentation, I'm 
> not sure how to do this.
>
> Can anyone help me with these two problems?
>

In the JSNI, only the "@package.Class::method(paramsignature)"  is special, 
the rest is just JavaScript; so your JSNI should read:

$wnd.js_funct_equiv = 
$entry(@com.lushprojects.curcuitjs1.client.CirSim::example_func(IFI));

(well, except that your method only takes an 'int' parameter, so the 
signature should be just "I", not "IFI", which would match 'int,float,int'. 
Note that you can use "(*)" instead of "(IFI)" if your method has no 
overload, so you don't have to keep the signature inJSNI synchronized with 
the actual method signature, could make maintenance easier)

-- 
You received this message because you are subscribed to the Google Groups "GWT 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-web-toolkit+unsubscr...@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

Reply via email to