PDA

View Full Version : [UNKNOWN]getActiveTab() answers Integer



TheBerliner
2 Oct 2009, 1:34 AM
getActiveTab() should answer aTabPanel. In my case if frequently (but not always) answers anInteger and this seems to be wrong following the documentation.

This only happens during the start-up when the UI is not yet visible. Is this a known bug and is there a fix for it available?

Here is the code:

app.ui['pagesTabsEC'].add({
id: panelName,
autoScroll: false,
layout: 'fit',
iconCls: 'tabs',
closable: true,
listeners: {activate: setSelectedTabActive},
items: aNewPageContainer
}).show();
var tabPanel = app.activeTab(); //this causes the error
And this is the code in class app that calls getActiveTab():

ECApp.prototype.activeTab = function(){
var panel = app.ui['pagesTabsEC'];
var tab = panel.getActiveTab(); // tab often is == 1
I should mention that there always exist another two tabs, which were created previouly, but none is yet visible.

Condor
2 Oct 2009, 3:25 AM
Yes, the docs are not completely correct.

Before the first layout of the TabPanel, activeItem will contain what you specified in the config object (which can be a component, string or integer). After layout it will contain the active component.

TheBerliner
2 Oct 2009, 3:55 AM
Yes, the docs are not completely correct.
1) Funny thing is that this does not always happen. Only in about 25% of all cases.

2) Thank you for once again confirming that my footer text and my various other claims regarding the "doc" are correct!
:)

evant
5 Oct 2009, 8:20 PM
Actually the docs do indicate this:



/**
* Returns the Component which is the currently active tab. <b>Note that before the TabPanel
* first activates a child Component, this method will return whatever was configured in the
* {@link #activeTab} config option.</b>
* @return {BoxComponent} The currently active child Component if one <i>is</i> active, or the {@link #activeTab} config value.
*/


That being said, I don't see any reason why it has to be this way. The active tab can be initialized to the component inside initComponent and then actually set to be active inside afterRender like what happens now.

Condor
5 Oct 2009, 10:03 PM
That being said, I don't see any reason why it has to be this way. The active tab can be initialized to the component inside initComponent and then actually set to be active inside afterRender like what happens now.

No, that would kill the autoTabs feature.

TheBerliner
5 Oct 2009, 11:15 PM
In my view, it'd be fine the way it is - as long as this was mentioned in the "doc". Back to my old subject.

You should give up generating the doc from the (published) source code. This is a bad idea and probably one cause for the sparse, frugal and insufficent documentation.