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 t
Create a method like this:
public static native void onMyButtonClick() /*-{
myJSfunction();
}-*/;
Bind your button like this:
myButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event)
{
onMyButtonClick();
}
});
Done!
Just make sure that the javascript containing your function is loaded before the generated GWT javascript.
Your welcome!
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();
}-*/;