Wednesday, June 1, 2016

Having trouble with GWT JSNI

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?

Kind regards,
Andrew

--
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+unsubscribe@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.

No comments:

Post a Comment