This happens also for perfectly 'legal' HTML:

    <div id="staticarea" />
    <div id="applicationarea">
      <div id="menuarea" />
      <div id="clientarea" />
      <div id="actionpanel" />
    </div>

(the reason for doing so is that by using CSS I can easily position
the four areas in the client area - see attached)
Here's the code that generates the AssertionError:

  public void onModuleLoad() {
    Container.getInstance().registerController(this);


    Panel clientarea = RootPanel.get("clientarea");
    Label holding = new Label();
    holding.setText("work in progress...");
    clientarea.add(holding);

    Panel menuarea = RootPanel.get("menuarea");
    MenuView menuView = new MenuView(menuarea);
    registerView(ViewType.MENU, menuView);
    menuView.render();

    // This causes the exception to be raised:
    Panel actionsarea = RootPanel.get("actionpanel");
    ActionsView actions = new ActionsView();
    actions.setMainPanel(actionsarea);
    registerView(ViewType.ACTION, actions);
    actions.render();
  }

IMHO this is a genuine GWT bug....

On Apr 28, 8:40 pm, Vitali Lovich <[email protected]> wrote:
> Yes.  Use GWT properly.  Don't use raw HTML.  That's your problem.
>
> Instead of adding an HTML widget that wraps a "<div>", use a SimplePanel &
> set it's id if you need to.  Look at the showcase - it shows you a brief
> overview of most (all?) the widgets GWT has.
>
> Think of using raw HTML in your app as something akin to JSNI - only do it
> if you know what you are doing, otherwise you're just going to shoot
> yourself in the foot.  The only time raw HTML is "commonly" used is in the
> constructor of some Widgets (you'll see a boolean asking if you want to
> treat the string as text or html).
>
> The rule of thumb to use is as follows:
>
> HTML element
>  |
>  v
> wrapping GWT root panel
>  |
>  v
> GWT widgets & panels
>  |
>  v
> HTML possible
>
> Do not put GWT widgets below HTML possible.  Do not wrap HTML possible in
> GWT widgets.  HTML element can have sibling elements that get wrapped with
> GWT.
>
> Hopefully this'll clarify it for you.
>
> On Tue, Apr 28, 2009 at 4:52 AM, kohlyn <[email protected]> wrote:
>
> > Any suggested workarounds?
>
> > I currently load a page layout in HTML (Header/Menu Bar/Footer) ...
> > then in each section I load different HTML layouts depending on the
> > user, and then I add the controls.
>
> > On Apr 27, 6:15 pm, Vitali Lovich <[email protected]> wrote:
> > > Yes this has already come up on the mailing list.  This was always
> > illegal,
> > > just uncaught prior to 1.6.  You cannot wrap two elements in GWT if they
> > > already have a parent/child relationship in the DOM (causes a mismatch in
> > > the trees).
>
> > > Do a search & you'll find the response from the GWT developer regarding
> > this
> > > issue.
>
> > > On Mon, Apr 27, 2009 at 11:12 AM, kohlyn <[email protected]> wrote:
>
> > > > I'm getting the following errors with 1.6.4 on a Mac.
>
> > > > "A widget that has an existing parent widget may not be added to the
> > > > detach list"
>
> > > > The HTML is:
>
> > > >  <body>
> > > >    <!-- OPTIONAL: include this if you want history support -->
> > > >    <iframe src="javascript:''" id="__gwt_historyFrame" tabIndex='-1'
> > > > style="position:absolute;width:0;height:0;border:0"></iframe>
> > > >    <h1>Web Application Starter Project</h1>
> > > >    <div id="testdiv"></div>
> > > >  </body>
>
> > > > Code:
>
> > > >        public void onModuleLoad() {
>
> > > >                HTMLPanel p = new HTMLPanel("<div id=\"testdiv2\">Test
> > Div
> > > > 2</
> > > > div>");
>
> > > >                RootPanel.get("testdiv").add(p);
>
> > > >                final TextBox txtUsername = new TextBox();
>
> > > >                RootPanel.get("testdiv2").add(txtUsername);
>
> > > >        }
> > > > }
>
> > > > This code worked in the 1.4 and 1.5 branches, but not 1.6.
>
> > > > The line:
>
> > > >   "RootPanel.get("testdiv2").add(txtUsername);"
>
> > > > throws the exception.
> > > >   "A widget that has an existing parent widget may not be added to
> > > > the detach list"
>
> > > > The problems appears to be with a new check in
> > > > RootPanel.detachOnWindowClose(Widget widget)
>
> > > >    assert !isElementChildOfWidget(widget.getElement()) : "A widget
> > > > that has "
> > > >        + "an existing parent widget may not be added to the detach
> > > > list";
>
> > > > RootPanel.isElementChildOfWidget(Element element) appears to fail
> > > > because I'm adding a widget to an already attached element.
>
> > > > Any work arounds/ideas would be greatly appreciated ... I have a 1.4
> > > > application that is based on dynamically loading page layouts from a
> > > > database.
>
> > > > Thanks.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to