Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    A widget that has an existing parent widget may not be added to the detach list

    Hi,

    Having troubles with Tabs when adding a MapWidget.

    public void onModuleLoad() {

    TabSet tabSet = new TabSet();
    tabSet.setSize("300px", "300px");

    Tab t1 = new Tab("Status");
    Tab t2 = new Tab("Map");

    MapWidget map = new MapWidget();

    Canvas c2 = new Canvas();
    c2.addChild(map);
    t2.setPane(c2);

    tabSet.setTabs(t1, t2);

    RootPanel.get().add(tabSet);
    }

    This gives an error with GWT 1.7.1 when selecting the second tab.

    ncaught JavaScript exception [java.lang.AssertionError: A widget that has an existing parent widget may not be added to the detach list
    at com.google.gwt.user.client.ui.RootPanel.detachOnWindowClose(RootPanel.java:122)
    at com.google.gwt.user.client.ui.RootPanel.get(RootPanel.java:197)
    at com.smartgwt.client.widgets.WidgetCanvas.onDraw(WidgetCanvas.java:39)
    at com.smartgwt.client.widgets.BaseWidget.rendered(BaseWidget.java:205)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)


    Using latest official google maps gwt API and latest nightly build of SmartGWT.

    Any input on this would be greatly appreciated.

    Thank you.

    -- Sven

    #2
    Try tabSet.draw() instead of RootPanel.get().add(tabSet) and see if that helps.

    Comment


      #3
      It does indeed fix the test case above.

      Problem is that i have a custom made cardlayout widget that im trying to migrate to SmartGWT.
      What it does is simply hideMember(oldLayout) and showMember(currentLayout).

      Fails for same reason as above...

      As i understand GWT 1.7 is more strict about this then the previous versions and so i search a workaround for smartGWT.

      Comment


        #4
        I also use a custom card layout adapted from the SmartGWT-extensions but I used hide and show for each member without problem.

        Comment


          #5
          Forgot to reply here.

          Thank you svjard. Your suggestion solved my issue.

          My CardLayoutManager was broken and it was as easy as getting the SmartGWT-extensions CardLayoutCanvas instead. Funny how such a simple class can fail. :)

          Comment


            #6
            I am getting the same error. I have a TabSet object, under a VLayout which is under the RootPanel, with two tabs defined. I get the error when switching from the first tab to the second. The suggestion to try "tabSet.draw()" does render and avoids the problem, but this is useless to me - it needs to be part of another hierarchy for proper display.

            Evidently this problem has existed since at least last November. Why hasn't it been fixed yet?

            Code:
            19:58:01.191 [ERROR] [com.olivercomputing.DocSearch.DocSearch] 19:58:01.189:MDN5:WARN:Log:java.lang.AssertionError: A widget that has an existing parent widget may not be added to the detach list
            com.smartgwt.client.core.JsObject$SGWT_WARN: 19:58:01.189:MDN5:WARN:Log:java.lang.AssertionError: A widget that has an existing parent widget may not be added to the detach list
                at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
                at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
                at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
                at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
                at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:105)
                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:637)

            Comment


              #7
              Don't be so fast to assume this is a SmartGWT issue. What is the other hierarchy your talking about. Please give some details if you wish to be helped.

              Comment


                #8
                By "other hierarchy" I mean having tabSet be a child of other widgets.

                I've done additional experimentation and it's difficult to pin down exactly when the problem starts to occur, but it appears to be based on complexity of the layout (i.e. nested layouts).

                As I indicated previously I have a two-tab TabSet object which is the second child of a VLayout object (the first child being an HLayout object with a single label as its child). If I use:

                // rootPanel.add(layout,5,5);
                layout.draw();

                then the layout and the tabs behave exactly as expected. If I do this:

                rootPanel.add(layout,5,5);
                // layout.draw();

                then only the first tab is ever displayed.

                Is it possible that mixing in a few non-SmartGWT object types (plain GWT) could be a contributing factor? I have a plain Image and Textbox object mixed in with SmartGWT objects.

                In any case, since the layout.draw() renders the objects exactly as expected, it's difficult to believe that this is not a bug somewhere in SmartGWT. I would just use this workaround except for two problems. First, not adding the widget hierarchy to the root panel makes it impossible to use Instantiation's GWT Designer. Second, I am not sure that leaving this step out won't cause some subtle problem later on.

                Comment


                  #9
                  The actual warning is an assertion that part of GWT not SmartGWT, so has everything to do with mixing the two APIs. Two things I would check, first try using what you have but cut out the GWT components and see if that works. Those are leaf objects right, your aren't doing a GWT component which contains a SmartGWT child? That is a good starting point. Second thing generally seen, but in your case I think your fine is when trying to add to a div, it must use the syntax
                  Code:
                  <div id="myid"></div>
                  not
                  <div id="myid"/>
                  I've never hit any issue with pure SmartGWT components and using RootPanel, but if you have some specific code you think is where the problem is that can be easily built and run post it.

                  Comment


                    #10
                    I attach the files for an example of the error.
                    The Item works only if putted in the first tab.
                    The second tab is not rendered.
                    Attached Files

                    Comment


                      #11
                      Any workaround?
                      I'm going to sign it as issue in google code.

                      Comment

                      Working...
                      X