Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
68
rated 0 times [  72] [ 4]  / answers: 1 / hits: 16327  / 12 Years ago, thu, august 16, 2012, 12:00:00

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.


More From » java

 Answers
24

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();
}-*/;

[#83601] Wednesday, August 15, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
leilanichasel

Total Points: 224
Total Questions: 112
Total Answers: 94

Location: Angola
Member since Wed, Apr 13, 2022
2 Years ago
;