本文介绍了从Java GWT代码中调用.js文件的Javascript函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在Java GWT代码中有一个按钮。我在脚本文件夹中有一个JavaScript文件。我想在按钮单击时访问该js文件的功能。
那么我怎样才能从Java GWT代码(按钮的单击事件)调用该方法..?
任何人都可以告诉我代码或访问js文件功能的方法。
感谢您的提前。
$因为你的代码不应该依赖于gwt链接器(以及它如何加载代码),所以你需要用正确的窗口对象作为前缀调用。 Reapp没有考虑到这一点。所以它实际上需要: pre $ public static native void onMyButtonClick()/ * - { $ wnd.myJSfunction (); } - * /;
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(); }-*/;
更多推荐
从Java GWT代码中调用.js文件的Javascript函数
发布评论