English 中文(简体)
从手写的Javascript中引领GWT方法
原标题:Calling GWT methods from handwritten Javascript

与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.

如果任何人都知道这些问题的解决办法(或实现那些试图做的事情的替代方法),那就非常感激。 提前感谢。

问题回答

你们需要做一些额外的工作。 因为你描述的方法只是在汇编时间才奏效。 在汇编了WT方法名称之后,这些名称被删除。 但有一个图书馆可以帮助您:gwt-exporter





相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签