与WT集团共同开发一个网络应用程序,我希望让用户能够将其功能延伸到某种Javascript AP,与WT中书写的对应核心互动。 基本上,这份联合材料计划将描绘出我的一些将实际工作的内部方法。
因此,为了做到这一点,我从WT/CONI官方文件中读到一个trick,即从GAWT中形成一个全球共同提交文件变量,并将它称作实际的GWT方法。 然后,通过这一变量,我手写的《联合材料法典》将发出这一呼吁。
Unfortunately I couldnt make it to work (the example contained syntax errors son im not sure that it has even been tested). Doing more research, i found on this site a similar solution that assigns the JS var an anonymous function that makes the call. It looks like this:
/*GWT code that assigns the anonymous function*/
private static native void loadWrapper() /*-{
$wnd.showMessage =
$entry(@com.Glob3Mobile.client.TestApi::msgBox());
}-*/;
public static void msgBox() {
Window.alert("hello");
}
这一解决办法充满希望,但我原意是能够发挥作用。 在我手写的《联合材料法典》中“窗口.showMessage();”时,它赢得了工作。 我发现这些问题:
- window.showMessage seems to be created but JS console says that its not a function, even though i inspected the dom tree and verified that the variable does contains a function.
- It seems like I always have to append the "window." preffix, since the var is being created within the window object. This is a considerably concerning issue, cause forcing users to write like this every time they want to call a function is really tedious.
如果任何人都知道这些问题的解决办法(或实现那些试图做的事情的替代方法),那就非常感激。 提前感谢。