从Java GWT代码中调用.js文件的Javascript函数

编程入门 行业动态 更新时间:2024-10-08 04:26:42
本文介绍了从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函数

本文发布于:2023-11-28 17:53:38,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1643385.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:函数   代码   文件   GWT   Java

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!