我正在使用GWT 2.4和MVP模式,所以我有Presenters和Views(没有UIBinder).我有其中一个问题.我有一个带有TabLayoutPanel的视图,里面有更多的小部件.如果我使用LayoutPanel一切正常,但如果我使用RootLayoutPanel我有错误.
public class JaviView extends Composite implements FacturasPresenter.Display {
private RootLayoutPanel rootLayoutPanel = RootLayoutPanel.get();
private TabLayoutPanel tabPanel;
//...more declarations
}
public JaviView(){
initWidget(rootLayoutPanel);
rootLayoutPanel.setSize("100%", "100%");
//...
tabPanel = new TabLayoutPanel(1.7, Unit.EM);
//add widgets to tabPanel
tabPanel.setWidth("100%");
rootLayoutPanel.add(tabPanel);
}
Run Code Online (Sandbox Code Playgroud)
我得到:这个小部件的父级没有实现HasWidgets.
Caused by: java.lang.IllegalStateException: This widget's parent does not implement HasWidgets
at com.google.gwt.user.client.ui.Widget.removeFromParent(Widget.java:204)
at com.google.gwt.user.client.ui.Composite.initWidget(Composite.java:145)
at contabilidad.presentation.client.view.facturas.JaviView.<init>(JaviView.java:318)
Run Code Online (Sandbox Code Playgroud)
第318行是:initWidget(rootLayoutPanel).如果我使用LayoutPanel我没有那个错误,但我需要使用RootLayoutPanel.
我已经复制了代码并粘贴到另一个View中,使用RootLayoutPanel并且工作正常,所以我不知道问题出在哪里.我一直在寻找解决方案几个小时.提前致谢.
全部跟踪:
10:16:49.595 [ERROR] [contabilidadweb] 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.HandlerManager.fireEvent(HandlerManager.java:129)
at com.google.gwt.user.client.ui.Widget.fireEvent(Widget.java:129) …Run Code Online (Sandbox Code Playgroud)