Search code examples
tabsnullsmartgwtcollisiondestroy

SmartGWT TabSet.destroy() and recreation



I was having ID collision of tab IDs when trying to recreate the same TabSet.
My case is the following : I have 3 Tabs in general, then some action creates a 4th one, some action happens in this 4th tab which is then closed, and I need to relaunch my app and redraw again the 3 general Tabs fetching new info from the database. Everything was working well, except this warning of collision which was not a blocking one anyway. In order to clean it, I followed Isomorphic's advice from this thread and tried destroying the TabSet in order to recreate it. I do:

if (myTabSet != null) {
    myTabSet.destroy();
}
myTabSet = new TabSet();
// setting TabSet properties
// creating Tabs and adding them to the TabSet

I noticed, however, in debug, that the TabSet is not being desroyed completely, just some of its properties, and that a new ID is being given to it. As a result, there are no more warnings, the tabs are created, but they're not populated.
My question is : why the TabSet is not becoming null upon destruction, and how can I recreate it with no collision of IDs?
Thanks in advance


Solution

  • I used to have the same problem and fixed it with:

    myTabSet.addCloseClickHandler(new CloseClickHandler() {
    
            @Override
            public void onCloseClick(TabCloseClickEvent event) {
                event.getTab().getPane().destroy(); 
            }
        });
    

    Apparently the tabset is not completely destroyed unless you destroy its pane. Maybe it will work for you !