gpt4 book ai didi

java - GWT JSNI : invoking applet methods?

转载 作者:搜寻专家 更新时间:2023-11-01 02:54:38 25 4
gpt4 key购买 nike

我有一个 GWT包含嵌入式小程序的应用程序。

我想使用 JNSI 让 GWT 按钮将数据推送到那个小程序,但目前我什至无法连接它。寻求帮助 - 似乎无法找到任何解决如何让事情说话的方法。

在我的入口点类中,我定义了:

 native void doSomething() /*-{
$doc.applet_id.doSomething();
}-*/;

我通过 ClickHandler 将其挂接到按钮。在小程序主类中,有一个 doSomething() 方法,在页面中我通过以下方式启动小程序:

 <script>
var attributes = {codebase:'http://localhost:8888/',
code:'Applet.class', archive:'applet_test.jar', id:'applet_id',
width:100, height:40} ;
var parameters = {fontSize:16, jnlp_href:'launcher.jnlp'} ;
var version = '1.6' ;
deployJava.runApplet(attributes, parameters, version);
</script>

堆栈跟踪是

 com.google.gwt.event.shared.UmbrellaException: One or more exceptions caught, see full set in UmbrellaException#getCauses
at com.google.gwt.event.shared.SimpleEventBus.doFire(SimpleEventBus.java:214)
at com.google.gwt.event.shared.SimpleEventBus.fireEvent(SimpleEventBus.java:103)
at com.google.gwt.event.shared.HandlerManager.fireEvent(HandlerManager.java:96)
at com.google.gwt.user.client.ui.Widget.fireEvent(Widget.java:107)
at com.google.gwt.event.dom.client.DomEvent.fireNativeEvent(DomEvent.java:116)
at com.google.gwt.user.client.ui.Widget.onBrowserEvent(Widget.java:155)
at com.google.gwt.user.client.DOM.dispatchEventImpl(DOM.java:1308)
at com.google.gwt.user.client.DOM.dispatchEvent(DOM.java:1264)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:157)
at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessagesWhileWaitingForReturn(BrowserChannelServer.java:326)
at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:207)
at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:126)
at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:561)
at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:269)
at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91)
at com.google.gwt.core.client.impl.Impl.apply(Impl.java)
at com.google.gwt.core.client.impl.Impl.entry0(Impl.java:214)
at sun.reflect.GeneratedMethodAccessor56.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:157)
at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChannelServer.java:281)
at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:531)
at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:352)
at java.lang.Thread.run(Thread.java:680)
Caused by: com.google.gwt.core.client.JavaScriptException: (TypeError): $doc.applet_id.doSomething is not a function

最佳答案

显然我的 jnlp 文件也需要

<param name="MAYSCRIPT" value="true"/>

<applet-desc>部分。添加MAYSCRIPT:true但是,属性似乎不起作用。

关于java - GWT JSNI : invoking applet methods?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4099978/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com