It seems the PopupPanel will try to remove itself from its parent each time of showing. The parent in this case is a composite which does not implement HasWidgets, hence the exception. Is this my misuse of PopupPanel or a GWT bug?
On Feb 21, 12:30 am, Tatchan <[email protected]> wrote: > Hi, > > I always get the exception: "java.lang.IllegalStateException: This > widget's parent does not implement HasWidgets" while trying to use a > Composite which wraps a PopupPanel. > A simple example: > > // The main application window > public class AppWindow extends Composite { > private final PopupPanel panel = new PopupPanel(true); > > public AppWindow() { > initWidget(panel); > } > > public void show() { > panel.setSize("300px", "300px"); > panel.add(new Label("Application Window")); > panel.show(); > } > > } > > // A button to trigger the application window > public class AppButton extends Composite { > private final Button button = new Button("App"); > private final AppWindow window; > > public AppButton(AppWindow window) { > this.window = window; > button.addClickHandler(new ClickHandler() { > @Override > public void onClick(ClickEvent event) { > AppButton.this.window.show(); > } > }); > > initWidget(button); > } > > } > > // Entry > public class Ping implements EntryPoint { > @Override > public void onModuleLoad() { > AppWindow window = new AppWindow(); > AppButton button = new AppButton(window); > RootPanel.get().add(button); > } > > } > > Now click the button I always get the expected exception :) . It's the > same if the trigger is done via an event bus (i.e., the AppButton > fires an event, the AppWindow catchs the event and show it self). > > Note that it's ok if AppWindow does NOT extend Composite. > > Could someone explain please? > > The stack trace: > > 00:29:42.628 [ERROR] [ping] Uncaught exception escaped > java.lang.IllegalStateException: This widget's parent does not > implement HasWidgets > at > com.google.gwt.user.client.ui.Widget.removeFromParent(Widget.java:127) > at > com.google.gwt.user.client.ui.ComplexPanel.add(ComplexPanel.java:84) > at > com.google.gwt.user.client.ui.AbsolutePanel.add(AbsolutePanel.java:75) > at com.google.gwt.user.client.ui.PopupPanel > $ResizeAnimation.onInstantaneousRun(PopupPanel.java:311) > at com.google.gwt.user.client.ui.PopupPanel > $ResizeAnimation.setState(PopupPanel.java:208) > at > com.google.gwt.user.client.ui.PopupPanel.setState(PopupPanel.java: > 1374) > at com.google.gwt.user.client.ui.PopupPanel.show(PopupPanel.java: > 969) > at com.oneo.ping.client.test.AppWindow.show(AppWindow.java:18) > at com.oneo.ping.client.test.AppButton$1.onClick(AppButton.java: > 17) > at > com.google.gwt.event.dom.client.ClickEvent.dispatch(ClickEvent.java: > 54) > at > com.google.gwt.event.dom.client.ClickEvent.dispatch(ClickEvent.java:1) > at com.google.gwt.event.shared.HandlerManager > $HandlerRegistry.fireEvent(HandlerManager.java:65) > at com.google.gwt.event.shared.HandlerManager > $HandlerRegistry.access$1(HandlerManager.java:53) > at > com.google.gwt.event.shared.HandlerManager.fireEvent(HandlerManager.java: > 178) > at com.google.gwt.user.client.ui.Widget.fireEvent(Widget.java:52) > at > com.google.gwt.event.dom.client.DomEvent.fireNativeEvent(DomEvent.java: > 116) > at com.google.gwt.user.client.ui.Widget.onBrowserEvent(Widget.java: > 100) > at > com.google.gwt.user.client.ui.Composite.onBrowserEvent(Composite.java: > 54) > at com.google.gwt.user.client.DOM.dispatchEventImpl(DOM.java:1307) > at com.google.gwt.user.client.DOM.dispatchEvent(DOM.java:1263) > at sun.reflect.GeneratedMethodAccessor13.invoke(Unknown Source) > at > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java: > 25) > at java.lang.reflect.Method.invoke(Method.java:597) > 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: > 157) > at > com.google.gwt.dev.shell.BrowserChannel.reactToMessagesWhileWaitingForReturn(BrowserChannel.java: > 1713) > at > com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java: > 165) > at > com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java: > 120) > at > com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java: > 507) > at > com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java: > 264) > 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:188) > at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source) > at > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java: > 25) > at java.lang.reflect.Method.invoke(Method.java:597) > 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: > 157) > at > com.google.gwt.dev.shell.BrowserChannel.reactToMessages(BrowserChannel.java: > 1668) > at > com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java: > 401) > at > com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java: > 222) > at java.lang.Thread.run(Thread.java:619) -- You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
