gpt4 book ai didi

java - 带有 HTMLPanel 和 addAndReplaceElement 方法的 GWT NoSuchElementException

转载 作者:可可西里 更新时间:2023-11-01 13:37:21 26 4
gpt4 key购买 nike

这里有一些解释。

如果我的 HTML 页面包含:

<div id="cancel_date">
<h3 id="cancel_date_title"></h3>

<table align="center">
<tr>
<td id="cancel_date_labelDetailService"></td>
<td id="cancel_date_detailService"></td>
</tr>
</table>
</div>

如果我的代码包含

HTMLPanel container = HTMLPanel.wrap(Document.get().getElementById("cancel_date"));

public void init(){
container.add(getMyWidget(), "cancel_date_detailService");
}

public void reload(){
container.addAndReplaceElement(getService(), "cancel_date_detailService");
}

我第一次加载我的页面时,我使用 init() 方法对其进行初始化。第二次及之后,我调用方法 reload()。我第一次调用 reload() 方法时,一切正常。但是之后,我有一个像这样的 NoSuchElementException :

ERROR: Uncaught exception escaped
com.google.gwt.event.shared.UmbrellaException: One or more exceptions caught, see full set in UmbrellaException#getCauses
at com.google.gwt.event.shared.EventBus.castFireEvent(EventBus.java:69)
at com.google.gwt.event.shared.SimpleEventBus.fireEvent(SimpleEventBus.java:57)
at be.mims.bookme.client.gui.component.MyCellTableFuturDates$7.onSuccess(MyCellTableFuturDates.java:134)
at be.mims.bookme.client.gui.component.MyCellTableFuturDates$7.onSuccess(MyCellTableFuturDates.java:1)
at com.google.gwt.user.client.rpc.impl.RequestCallbackAdapter.onResponseReceived(RequestCallbackAdapter.java:232)
at com.google.gwt.http.client.Request.fireOnResponseReceived(Request.java:287)
at com.google.gwt.http.client.RequestBuilder$1.onReadyStateChange(RequestBuilder.java:395)
at sun.reflect.GeneratedMethodAccessor88.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
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:172)
at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessagesWhileWaitingForReturn(BrowserChannelServer.java:337)
at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:218)
at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136)
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:213)
at sun.reflect.GeneratedMethodAccessor79.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
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:172)
at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChannelServer.java:292)
at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:546)
at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:363)
at java.lang.Thread.run(Thread.java:722)
Caused by: java.util.NoSuchElementException: cancel_date_detailService
at com.google.gwt.user.client.ui.HTMLPanel.addAndReplaceElement(HTMLPanel.java:224)
at be.mims.bookme.client.gui.FactoryCancelDate.showCancelDate(FactoryCancelDate.java:128)
at be.mims.bookme.client.BookMe.show(BookMe.java:277)
at be.mims.bookme.client.event.StateEvent.dispatch(StateEvent.java:31)
at be.mims.bookme.client.event.StateEvent.dispatch(StateEvent.java:1)
at com.google.gwt.event.shared.GwtEvent.dispatch(GwtEvent.java:1)
at com.google.web.bindery.event.shared.EventBus.dispatchEvent(EventBus.java:40)
at com.google.web.bindery.event.shared.SimpleEventBus.doFire(SimpleEventBus.java:193)
at com.google.web.bindery.event.shared.SimpleEventBus.fireEvent(SimpleEventBus.java:88)
at com.google.gwt.event.shared.SimpleEventBus.fireEvent(SimpleEventBus.java:52)
at com.google.gwt.event.shared.EventBus.castFireEvent(EventBus.java:67)
at com.google.gwt.event.shared.SimpleEventBus.fireEvent(SimpleEventBus.java:57)
at be.mims.bookme.client.gui.component.MyCellTableFuturDates$7.onSuccess(MyCellTableFuturDates.java:134)
at be.mims.bookme.client.gui.component.MyCellTableFuturDates$7.onSuccess(MyCellTableFuturDates.java:1)
at com.google.gwt.user.client.rpc.impl.RequestCallbackAdapter.onResponseReceived(RequestCallbackAdapter.java:232)
at com.google.gwt.http.client.Request.fireOnResponseReceived(Request.java:287)
at com.google.gwt.http.client.RequestBuilder$1.onReadyStateChange(RequestBuilder.java:395)
at sun.reflect.GeneratedMethodAccessor88.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
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:172)
at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessagesWhileWaitingForReturn(BrowserChannelServer.java:337)
at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:218)
at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136)
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:213)
at sun.reflect.GeneratedMethodAccessor79.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
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:172)
at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChannelServer.java:292)
at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:546)
at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:363)
at java.lang.Thread.run(Thread.java:722)

如果我进入 SimpleEventBus 类,哪里有异常:

java.util.NoSuchElementException: cancel_date_detailService
at com.google.gwt.user.client.ui.HTMLPanel.addAndReplaceElement(HTMLPanel.java:224)
at be.mims.bookme.client.gui.FactoryDetailRdv.showDetailsDate(FactoryDetailRdv.java:72)
at be.mims.bookme.client.BookMe.show(BookMe.java:228)
at be.mims.bookme.client.event.StateEvent.dispatch(StateEvent.java:31)
at be.mims.bookme.client.event.StateEvent.dispatch(StateEvent.java:1)
at com.google.gwt.event.shared.GwtEvent.dispatch(GwtEvent.java:1)
at com.google.web.bindery.event.shared.EventBus.dispatchEvent(EventBus.java:40)
at com.google.web.bindery.event.shared.SimpleEventBus.doFire(SimpleEventBus.java:193)
at com.google.web.bindery.event.shared.SimpleEventBus.fireEvent(SimpleEventBus.java:88)
at com.google.gwt.event.shared.SimpleEventBus.fireEvent(SimpleEventBus.java:52)
at com.google.gwt.event.shared.EventBus.castFireEvent(EventBus.java:67)
at com.google.gwt.event.shared.SimpleEventBus.fireEvent(SimpleEventBus.java:57)
at be.mims.bookme.client.gui.component.MyCellTableFuturDates$7.onSuccess(MyCellTableFuturDates.java:130)
at be.mims.bookme.client.gui.component.MyCellTableFuturDates$7.onSuccess(MyCellTableFuturDates.java:1)
at com.google.gwt.user.client.rpc.impl.RequestCallbackAdapter.onResponseReceived(RequestCallbackAdapter.java:232)
at com.google.gwt.http.client.Request.fireOnResponseReceived(Request.java:287)
at com.google.gwt.http.client.RequestBuilder$1.onReadyStateChange(RequestBuilder.java:395)
at sun.reflect.GeneratedMethodAccessor174.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
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:172)
at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessagesWhileWaitingForReturn(BrowserChannelServer.java:337)
at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:218)
at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136)
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:213)
at sun.reflect.GeneratedMethodAccessor166.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
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:172)
at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChannelServer.java:292)
at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:546)
at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:363)
at java.lang.Thread.run(Thread.java:722)

我使用 GWT 2.4.0

非常感谢您的帮助!!!

最佳答案

顾名思义,addAndReplaceElement 找到元素并用给定的小部件替换它。一旦你为一个元素调用了一次 addAndReplaceElement,那个元素就消失了,所以第二次调用显然不会找到它,导致你看到的 NoSuchElementException

如果你想用另一个替换你的小部件,那么你需要将它包装在一个元素中(即调用add而不是addAndReplaceElement),并使用 remove 删除之前的小部件。

关于java - 带有 HTMLPanel 和 addAndReplaceElement 方法的 GWT NoSuchElementException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13380162/

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