Calling the Javascript function of the .js file from the GWT Java code

advertisements

I have one button in Java GWT code. And I have one javascript file in scripts folder. I want to access functions of that js file on Button click.

So how can I call that method from Java GWT code(Button's click event)..?

Can anyone please tell me code or way for accessing js file's function.

Thanks in Advance.


since your code should not depend on the gwt linker (and how it loads code) you need to prefix the call with the right window object. Reapp does not take that into account. So it actually needs to be:

public static native void onMyButtonClick() /*-{
    $wnd.myJSfunction();
}-*/;