GWTP,SmartGWT,将GWT小部件添加到SmartGWT时出错

GWTP,SmartGWT,将GWT小部件添加到SmartGWT时出错,gwt,smartgwt,gwtp,Gwt,Smartgwt,Gwtp,我使用的是GWT2.4、SmartGWT3.0和GWTP 0.7 我主要尝试在布局中使用SmartGWT小部件,但我尝试将GWT小部件(可以是从HighCharts或GWT标签中的MapWidget到ChartWidget的任何内容)添加到SmartGWT选项卡集中的选项卡。然后我得到以下异常: Caused by: java.lang.AssertionError: A widget that has an existing parent widget may not be added to

我使用的是GWT2.4、SmartGWT3.0和GWTP 0.7

我主要尝试在布局中使用SmartGWT小部件,但我尝试将GWT小部件(可以是从HighCharts或GWT标签中的MapWidget到ChartWidget的任何内容)添加到SmartGWT选项卡集中的选项卡。然后我得到以下异常:

Caused by: java.lang.AssertionError: A widget that has an existing parent widget may not be added to the detach list
这仅在开发模式下发生。在生产环境中,断言已经被关闭,我的小部件确实会出现,但这使得在开发模式下调试变得不可能。据我所知,这是因为我混合了SmartGWT和GWT小部件

在GWTP之前,我能够做到这一点,因为为了显示我的UI,我会在我的根布局上调用
draw()
,这是一个VLayout。现在我正在使用GWTP,当我启动
RevealRootContentEvent
时,它将为我显示布局,并通过调用
RootPanel.get().add(…)
来添加布局,我认为这就是我现在遇到这些问题的原因。我的所有布局仍在SmartGWT中


有没有人遇到过同样的问题(在相同的设置中)以及如何处理这些问题?

所以我想我已经找到了问题的根源

我读了这期

在其中一篇文章中,介绍了如何创建自定义RootPresenter。RootPresenter还包含一个RootView,其中放置了前面提到的
setInSlot
方法,通过编写自定义视图,可以覆盖该方法,并确保在SmartGWT布局上调用
draw()
,而不是添加到
RootPanel.get().add(…)

我的impl如下所示:

公共类CustomRootPresenter扩展了RootPresenter
{
公共静态最终类CustomRootView扩展了RootView
{
@凌驾
公共void setInSlot(对象槽、小部件内容)
{
if(布局的内容实例)
{
//清楚的
RootLayoutPanel.get().clear();
RootPanel.get().clear();
布局=(布局)内容;
layout.draw();
}
其他的
{
super.setInSlot(槽、内容);
}
}
}
@注入
公共CustomRootPresenter(EventBus EventBus、CustomRootView myRootView)
{
超级(eventBus,myRootView);
}
}
请记住在GIN模块中插入自定义根演示者:

//使用自定义RootPresenter时,不要使用install
//安装(新的DefaultModule(ClientPlaceManager.class));
绑定(EventBus.class).to(SimpleEventBus.class).in(Singleton.class);
绑定(TokenFormatter.class).to(ParameterTokenFormatter.class).in(Singleton.class);
bind(CustomRootPresenter.class).asEagerSingleton();
绑定(PlaceManager.class).to(ClientPlaceManager.class).in(Singleton.class);
绑定(GoogleAnalytics.class).to(GoogleAnalyticsImpl.class).in(Singleton.class);
它确实解决了我在SmartGWT布局中添加GWT小部件的问题


感谢让·米歇尔·加西亚把我推向了正确的方向!:)

所以我想我找到了问题的根源

我读了这期

在其中一篇文章中,介绍了如何创建自定义RootPresenter。RootPresenter还包含一个RootView,其中放置了前面提到的
setInSlot
方法,通过编写自定义视图,可以覆盖该方法,并确保在SmartGWT布局上调用
draw()
,而不是添加到
RootPanel.get().add(…)

我的impl如下所示:

公共类CustomRootPresenter扩展了RootPresenter
{
公共静态最终类CustomRootView扩展了RootView
{
@凌驾
公共void setInSlot(对象槽、小部件内容)
{
if(布局的内容实例)
{
//清楚的
RootLayoutPanel.get().clear();
RootPanel.get().clear();
布局=(布局)内容;
layout.draw();
}
其他的
{
super.setInSlot(槽、内容);
}
}
}
@注入
公共CustomRootPresenter(EventBus EventBus、CustomRootView myRootView)
{
超级(eventBus,myRootView);
}
}
请记住在GIN模块中插入自定义根演示者:

//使用自定义RootPresenter时,不要使用install
//安装(新的DefaultModule(ClientPlaceManager.class));
绑定(EventBus.class).to(SimpleEventBus.class).in(Singleton.class);
绑定(TokenFormatter.class).to(ParameterTokenFormatter.class).in(Singleton.class);
bind(CustomRootPresenter.class).asEagerSingleton();
绑定(PlaceManager.class).to(ClientPlaceManager.class).in(Singleton.class);
绑定(GoogleAnalytics.class).to(GoogleAnalyticsImpl.class).in(Singleton.class);
它确实解决了我在SmartGWT布局中添加GWT小部件的问题


感谢让·米歇尔·加西亚把我推向了正确的方向!:)

难道你不能摆脱
RootPanel.get().add()
而只使用
draw
方法吗?您的问题与
RootPanel.get().add()直接相关。
callI我没有直接调用RootPanel.get().add()。这是在GWTP的RootPresenter.setInSlot中完成的。我想你的建议是克隆GWTP源代码,并创建我自己的自定义版本?那么为什么不重写setinslot呢?我不知道如何才能做到这一点。我有我的LoginPresenter,它扩展了Presenter。在这里,我可以覆盖setInSlot(对象槽、PresenterWidget内容),但从未调用此方法。与LoginView相同,它是从ViewImpl扩展而来的。在这里,我可以覆盖setInSlot(对象槽,小部件内容),但是这个也从来没有被调用过……或者你提到过克隆GWTP src并覆盖setInSlot吗?(因为现在我试图在我自己的代码中重写这个特定的方法,它使用的是原始的gwtp src)你不能去掉
RootPanel.ge吗