Announcement

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

    Existing Parent Widget?

    Hi, this is a problem that has bugged me for weeks if not longer.
    I am able to work around it temporary, but i will encounter the same problem somewhere down the line. I have searched/googled and none of the solutions/suggestion helped. I would like to know fundamentally, what's wrong with the code.

    The error recieved is as follows:
    Uncaught JavaScript exception [uncaught exception: java.lang.AssertionError: A widget that has an existing parent widget may not be added to the detach list] in , line 0

    Following is the code :
    Code:
    	public void onModuleLoad()
    	{
    
    		TabSet mMainTab = new TabSet();
    
    		Tab tab1 = new Tab("TAB1");
    		HLayout layout1 = new HLayout();
    
    		tab1.setPane(layout1);
    
    		Tab tab2 = new Tab("TAB2");
    		Canvas debugCanvas = new Canvas();
    		final ScrollPanel mMainContent = new ScrollPanel();
    		debugCanvas.addChild(mMainContent);
    		tab2.setPane(debugCanvas);
    		
    		mMainTab.addTab(tab1);
    		mMainTab.addTab(tab2);
    
    		mMainTab.setWidth100();
    		mMainTab.setHeight100();
    
    		RootPanel.get().add(mMainTab);
    	}
    To reproduce the error, simply click on Tab2.
    As mentioned, i have found workarounds like swapping tab1 and tab2 will work. But that's not what i'm interested. As i develop further, I will encounter this problem again.

    Thanks in advance. Any inputs/insight to this issue is appreciated.
    Last edited by elnzhaoyun; 21 Jun 2010, 18:58.

    #2
    Change the last line to mMainTab.draw() instead. BTW why use a scrollpanel, there are simple alternatives in SmartGWT
    Last edited by svjard; 22 Jun 2010, 08:41.

    Comment


      #3
      Thanks svjard. That works.
      So i'm assuming that creating canvas item implies that it's already added to the page? so i just have to perform a draw?

      I am using a scroll panel as other widgets like SimplePanel, VLayout, VStack seems not able to do what i'm trying to achieve. I might be using it wrongly though.

      I have a HLayout which contains a SectionStack and a Panel.
      This HLayout fills the page via setWidth100 and setHeight100.
      However, i want the panel that's on the right to come with a scroll bar when the items in it gets too many.

      Thanks once again for the valuable info.

      Comment


        #4
        Creating a canvas does not imply it is part of the page automatically, if you run your code in hosted mode you can drill down to find out what GWT is doing that causes that assertion. But without going into that detail, basically depending on how you mix SmartGWT with core GWT components you can run into issues. It is pretty easy to create a vertically scrolling Canvas in SmartGWT if you have set Overflow correctly, it will produce a scrollbar when needed.

        Comment

        Working...
        X