Managing Widgets that GWT did not generate

6 views
Skip to first unread message

tieTYT

unread,
Nov 24, 2008, 7:53:01 PM11/24/08
to Google Web Toolkit
Hello,

For reasons explained in this thread,
http://groups.google.com/group/Google-Web-Toolkit/browse_thread/thread/9a050d74a6cd22bc#
, I need to define some HTML in the HTML document. The rest of the
page is generated by GWT. The problem is, I can't figure out a way to
take my formPanel, defined like this, FormPanel formPanel =
FormPanel.wrap(DOM.getElementById("loginForm"), true);

And add it to a basePanel that's been defined like this: basePanel =
new VerticalPanel();

I get an exception like this:
java.lang.IllegalStateException: Should only call onAttach when the
widget is detached from the browser's document
at com.google.gwt.user.client.ui.Widget.onAttach(Widget.java:105)
at com.google.gwt.user.client.ui.FormPanel.onAttach(FormPanel.java:
382)
at com.google.gwt.user.client.ui.Panel.doAttachChildren(Panel.java:
165)
at com.google.gwt.user.client.ui.Widget.onAttach(Widget.java:111)
at com.google.gwt.user.client.ui.Widget.setParent(Widget.java:231)
at com.google.gwt.user.client.ui.Panel.adopt(Panel.java:119)
at com.google.gwt.user.client.ui.ComplexPanel.add(ComplexPanel.java:
86)
at com.google.gwt.user.client.ui.AbsolutePanel.add(AbsolutePanel.java:
80)
at silverpop.sandbox.client.Sandbox.onModuleLoad(Sandbox.java:62)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke
(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke
(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at com.google.gwt.dev.shell.ModuleSpace.onLoad(ModuleSpace.java:320)
at com.google.gwt.dev.shell.BrowserWidget.attachModuleSpace
(BrowserWidget.java:329)
at com.google.gwt.dev.shell.ie.BrowserWidgetIE6.access$300
(BrowserWidgetIE6.java:37)
at com.google.gwt.dev.shell.ie.BrowserWidgetIE6$External.gwtOnLoad
(BrowserWidgetIE6.java:76)
at com.google.gwt.dev.shell.ie.BrowserWidgetIE6$External.invoke
(BrowserWidgetIE6.java:139)
at com.google.gwt.dev.shell.ie.IDispatchImpl.Invoke
(IDispatchImpl.java:294)
at com.google.gwt.dev.shell.ie.IDispatchImpl.method6
(IDispatchImpl.java:194)
at org.eclipse.swt.internal.ole.win32.COMObject.callback6
(COMObject.java:117)
at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:1925)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2966)
at com.google.gwt.dev.GWTShell.pumpEventLoop(GWTShell.java:720)
at com.google.gwt.dev.GWTShell.run(GWTShell.java:593)
at com.google.gwt.dev.GWTShell.main(GWTShell.java:357)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke
(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke
(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:
90)

So, is there a way to move HTML from the document into GWT generated
panel's? My alternative is to add the whole layout of the page into
the HTML and put placeholders in it that GWT populates. I'd like to
avoid that.

Thomas Broyer

unread,
Nov 26, 2008, 10:55:33 AM11/26/08
to Google Web Toolkit


On 25 nov, 01:53, tieTYT <tie...@gmail.com> wrote:
> Hello,
>
> For reasons explained in this thread,
> http://groups.google.com/group/Google-Web-Toolkit/browse_thread/thread/9a050d74a6cd22bc#
> , I need to define some HTML in the HTML document.  The rest of the
> page is generated by GWT.  The problem is, I can't figure out a way to
> take my formPanel, defined like this, FormPanel formPanel =
> FormPanel.wrap(DOM.getElementById("loginForm"), true);
> And add it to a basePanel that's been defined like this: basePanel =
> new VerticalPanel();

If you do this, you'll likely lose the form's autocomplete (just
guessing, I haven't tried it)

> So, is there a way to move HTML from the document into GWT generated
> panel's?

You could move the DOM element, not the widget (this means you won't
have your FormPanel as a child of your VerticalPanel, and your
VerticalPanel will be in some kind of "inconsistent" state: its DOM
structure has been changed without it being notified, so some things
might break).

> My alternative is to add the whole layout of the page into
> the HTML and put placeholders in it that GWT populates.  I'd like to
> avoid that.

That's the Best Thing (TM) to do IMO. Why would you like to avoid this
approach?

Reply all
Reply to author
Forward
0 new messages