I’m using GWT 2.4, SmartGWT 3.0, GWTP 0.7.
I mostly try to stick with SmartGWT widgets for my layout, but I’m trying to add a GWT widget (can be anything from a MapWidget to a ChartWidget from HighCharts or a GWT label) to a tab in the SmartGWT tabset. Then I get the following exception:
Caused by: java.lang.AssertionError: A widget that has an existing parent widget may not be added to the detach list
This only happens in Dev mode. In production the assertions have been turned off, and my widgets do show up, but it makes it impossible to debug in Dev mode. As I understand it is because I’m mixing SmartGWT and GWT widgets.
Before GWTP, I was able to make this work, because to show my UI I would call draw() on my root layout, which was a VLayout. Now that I’m using GWTP, it will show my layout for me when I fire the RevealRootContentEvent, and it will add the layout by calling RootPanel.get().add(...), which I think is the reason why I’m having these problems now. All my layouts are still in SmartGWT.
Has anyone experienced the same issues (in the same setup) and how can this be handled?
So I think I got to the bottom of my problem.
I read this issue
http://code.google.com/p/gwt-platform/issues/detail?id=127
In one of the posts, it is shown how to create a custom RootPresenter. The RootPresenter also contains a RootView, where the aforementioned
setInSlotmethod is placed, and by writing a custom view, it is possible to override that method, and make sure thatdraw()is invoked on SmartGWT layouts, rather than being added inRootPanel.get().add(...);My impl looks like this:
Remember to inject the custom root presenter in your GIN module:
It definitely solved my problem with adding GWT widgets to SmartGWT layouts.
Thanks to Jean-Michel Garcia for pushing me in the right direction! 🙂