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

    I am having an issue when I try to "remove" and "add" a widget/canvas to the parent.
    I have seen the response for this issue earlier in the existing thread but not able to get the response properly

    Eg:
    Code:
     parent1.add(widget1);
     parent1.add(widget2);
     parent1.add(widget3);
    ...
    ...
    ...
    UpdateChart(){
     widget1.removeFromParent();
     widget1 = getNewChart();
     parent1.addChild(widget1); // This is the place I am getting the error
    }
    Not sure I am following the sequence of steps correctly or something I am missing. I would appreciate if you could help me with the sample to fix the issue.

    Below is the error Trace:

    Code:
    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:136)
        at com.google.gwt.user.client.ui.RootPanel.get(RootPanel.java:211)
        at com.smartgwt.client.widgets.WidgetCanvas.onDraw(WidgetCanvas.java:39)
        at com.smartgwt.client.widgets.BaseWidget.rendered(BaseWidget.java:285)
        at sun.reflect.GeneratedMethodAccessor52.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:172)
        at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessagesWhileWaitingForReturn(BrowserChannelServer.java:337)
        at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:218)
        at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136)
        at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:561)
        at com.google.gwt.dev.shell.ModuleSpace.invokeNativeVoid(ModuleSpace.java:289)
        at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeVoid(JavaScriptHost.java:107)
        at com.smartgwt.client.widgets.BaseWidget.draw(BaseWidget.java)
    Thanks
    Kumar.
    Last edited by myIso; 16 Apr 2014, 08:25. Reason: Error Trace added.

    #2
    Wrong forum (we moved it to the right one).

    See FAQ - you appear to be mixing GWT and SmartGWT widgets invalidly. Or, perhaps you are using RootPanel.add() instead of draw() - use draw() instead (see QuickStart Guide).

    If you think neither of the above causes apply, please try to put together simple, runnable code that produces this error.

    Comment


      #3
      Example Code for the issue..

      As requested a sample, please find the details below. I have added two children to a pane, then removed one child and re-add a new child and there I see the error. I am not sure if the steps I am taking are correct. I would appreciate if provided with the correct steps to be taken to remove and add the child in the below code.

      Code:
      package com.samples.client;
      
      import com.google.gwt.core.client.EntryPoint;
      import com.google.gwt.user.client.ui.Label;
      import com.google.gwt.user.client.ui.RootPanel;
      import com.smartgwt.client.widgets.Canvas;
      import com.smartgwt.client.widgets.WidgetCanvas;
      import com.smartgwt.client.widgets.layout.HLayout;
      
      public class HelloWorld implements EntryPoint {
      
      	final HLayout mainPane = new HLayout();
      	
      	@Override
      	public void onModuleLoad() {
      		RootPanel.get().add(new Label("Hello World"));
      		
      		 mainPane.setWidth(720);
      	     mainPane.setHeight(261);
      	     
      	     WidgetCanvas canvas1 = new WidgetCanvas(new Label("Test"));
      	     Canvas canvas2 = new Canvas();
      	     canvas2.setWidth(100);
      	     canvas2.addChild(new Label("Test2"));
      	     
      	     mainPane.addChild(canvas1);
      	     mainPane.addChild(canvas2);
      	     
      	     RootPanel.get().add(mainPane);
      	     
      	     canvas2.removeFromParent();
      	     canvas2.destroy();
      	     canvas2 = new Canvas();
      	     canvas2.setWidth(200);
      	     canvas2.addChild(new Label("TESTTTTTTTTTTTTTTTTTTTTT"));
      	     
      	     mainPane.addChild(canvas2); // Error in this Line...
      	     mainPane.draw();
      	     
      	}
      
      }
      Error:
      Code:
      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:136)
          at com.google.gwt.user.client.ui.RootPanel.get(RootPanel.java:211)
          at com.smartgwt.client.widgets.WidgetCanvas.onDraw(WidgetCanvas.java:39)
          at com.smartgwt.client.widgets.BaseWidget.rendered(BaseWidget.java:285)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
          at java.lang.reflect.Method.invoke(Unknown Source)
          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:172)
          at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessagesWhileWaitingForReturn(BrowserChannelServer.java:338)
          at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:219)
          at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136)
          at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:571)
          at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:279)
          at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91)
          at com.smartgwt.client.widgets.Canvas.addChild(Canvas.java)
          at com.samples.client.HelloWorld.onModuleLoad(HelloWorld.java:37)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
          at java.lang.reflect.Method.invoke(Unknown Source)
          at com.google.gwt.dev.shell.ModuleSpace.onLoad(ModuleSpace.java:406)
          at com.google.gwt.dev.shell.OophmSessionHandler.loadModule(OophmSessionHandler.java:200)
          at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:526)
          at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:364)
          at java.lang.Thread.run(Unknown Source)
      Gwt.xml:

      Code:
      <?xml version="1.0" encoding="UTF-8"?>
      <!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.5.1//EN" "http://google-web-toolkit.googlecode.com/svn/tags/2.5.1/distro-source/core/src/gwt-module.dtd">
      <module>
      	<inherits name="com.google.gwt.user.User" />
      	<inherits name="com.smartgwt.SmartGwt"/>
      	<source path="client" />
      	<entry-point class="com.samples.client.HelloWorld" />
      </module>
      Originally posted by Isomorphic View Post
      Wrong forum (we moved it to the right one).

      See FAQ - you appear to be mixing GWT and SmartGWT widgets invalidly. Or, perhaps you are using RootPanel.add() instead of draw() - use draw() instead (see QuickStart Guide).

      If you think neither of the above causes apply, please try to put together simple, runnable code that produces this error.
      Last edited by myIso; 17 Apr 2014, 10:44.

      Comment


        #4
        So this code obviously violates the guidelines provided in the FAQ.

        Comment


          #5
          Can you please help me provide what it violates and where? I would appreciate your response.

          Originally posted by Isomorphic View Post
          So this code obviously violates the guidelines provided in the FAQ.

          Comment


            #6
            RootPanel.add() instead of draw().

            Comment


              #7
              It should be like the replacing with a new child. With RootPanel.add() how will I know where to replace?

              I would be really much appreciated if you could update the code I have provided in this thread and paste it as a new response, so it will be easy for me to make changes.

              Originally posted by Isomorphic View Post
              RootPanel.add() instead of draw().
              Thanks a lot!!

              Comment


                #8
                All SmartGWT widgets have the ability to add and remove children.

                If you would like hands-on assistance and/or code to be written for you, please consider our commercial services. Expecting intensive free help with a free product is not reasonable and drains resources away from users who make better use of the documentation.

                Comment


                  #9
                  I tried as per your suggestion but did not work. It is not replacing but placing it some where else on the screen.

                  If not can you please direct me to your documentation or showcase example how to use of remove and add children in smartgwt?


                  Originally posted by Isomorphic View Post
                  All SmartGWT widgets have the ability to add and remove children.

                  If you would like hands-on assistance and/or code to be written for you, please consider our commercial services. Expecting intensive free help with a free product is not reasonable and drains resources away from users who make better use of the documentation.

                  Comment

                  Working...
                  X