我正在使用GWT。在我的主頁中有以下代碼。將小部件添加到iframe時出現異常?
<div id="mainDiv"/>
<iframe id="__printingFrame" style="width:0;height:0;border:0"> </iframe>
在入口點的onModuleLoad()我有下面的代碼:
@Override
public void onModuleLoad() {
RootPanel.get("mainDiv").add(new SomePage());
}
在SomePage.java我在做的方法之一:
RootPanel rootPanel = RootPanel.get("__printingFrame");
rootPanel.add(new Html(" "));//adding some widget
但bcaz上面一行的我我正處於例外之下。我在這裏錯過了什麼?
java.lang.AssertionError: A widget that has an existing parent widget may not be added to the detach list
at com.google.gwt.user.client.ui.RootPanel.detachOnWindowClose(RootPanel.java:136)
at com.google.gwt.user.client.ui.RootPanel.get(RootPanel.java:211)
謝謝!