timefortea
10 Oct 2008, 6:24 AM
Hi all,
I've just started trying to port our HTML app to GXT and have encountered my first problem. Basically, a tab bar will be drawn according to a user's credentials, so a login window must be drawn first. Then once the user has authenticated, the retrieved credentials are used to determine what tabs are to be created. The problem is that when the tabs are created, I want to programmatically select which is the active tab - for which I am using:
tabPanel.setSelection(thisTab);This does work but I am setting a listener on each TabItem and it appears that despite setting which TabItem is to be selected, the listener on the first TabItem is always called first, before the chosen TabItem is selected (assume the first TabItem is not the one being selected).
I tried out a few tests and this does not happen pre-rendering. I am creating the TabPanel and it is being rendered behind the login window - then once the user authenticates, the details are being used to create the tabs. So am I doing something wrong? My understanding of the event model is limited and I've been unable to find much documentation on it so far.
Here is my code that is (re)creating the tabs:
public void buildTabBar()
{
<snip>
tabPanel.disableEvents(true);
tabPanel.hide();
tabPanel.removeAll();
for (String appName: appNames)
{
TabItem tabItem = new TabItem(appName);
if (!thisAppName.equals(appName))
{
tabItem.addListener(Events.Select, new SelectionListener<ComponentEvent>()
{
public void componentSelected(ComponentEvent be)
{
TabPanelEvent tbe = (TabPanelEvent)be;
TabItem tbi = (TabItem)tbe.item;
String appName = tbi.getText();
String url = sd.getUserCredentials().getURL(appName);
Window.Location.assign(url);
}
});
}
else
{
thisTab = tabItem;
}
tabPanel.add(tabItem);
tabPanel.setSelection(thisTab);
}
tabPanel.show();
tabPanel.enableEvents(true);
}
Any help appreciated.
I've just started trying to port our HTML app to GXT and have encountered my first problem. Basically, a tab bar will be drawn according to a user's credentials, so a login window must be drawn first. Then once the user has authenticated, the retrieved credentials are used to determine what tabs are to be created. The problem is that when the tabs are created, I want to programmatically select which is the active tab - for which I am using:
tabPanel.setSelection(thisTab);This does work but I am setting a listener on each TabItem and it appears that despite setting which TabItem is to be selected, the listener on the first TabItem is always called first, before the chosen TabItem is selected (assume the first TabItem is not the one being selected).
I tried out a few tests and this does not happen pre-rendering. I am creating the TabPanel and it is being rendered behind the login window - then once the user authenticates, the details are being used to create the tabs. So am I doing something wrong? My understanding of the event model is limited and I've been unable to find much documentation on it so far.
Here is my code that is (re)creating the tabs:
public void buildTabBar()
{
<snip>
tabPanel.disableEvents(true);
tabPanel.hide();
tabPanel.removeAll();
for (String appName: appNames)
{
TabItem tabItem = new TabItem(appName);
if (!thisAppName.equals(appName))
{
tabItem.addListener(Events.Select, new SelectionListener<ComponentEvent>()
{
public void componentSelected(ComponentEvent be)
{
TabPanelEvent tbe = (TabPanelEvent)be;
TabItem tbi = (TabItem)tbe.item;
String appName = tbi.getText();
String url = sd.getUserCredentials().getURL(appName);
Window.Location.assign(url);
}
});
}
else
{
thisTab = tabItem;
}
tabPanel.add(tabItem);
tabPanel.setSelection(thisTab);
}
tabPanel.show();
tabPanel.enableEvents(true);
}
Any help appreciated.