PDA

View Full Version : [CLOSED] TabPanel in a Content Panel Bug



jkriesel
8 Jul 2009, 6:57 AM
I have a problem when a tab panel is contained in a content panel. Clicking from tab to tab breaks. Also notice the strange behavior in that the tabs do not display until you resize.

It occurs on Windows in both hosted and web mode with Ext GWT 2.0 (downloaded yesterday).

Here is an example source:


package com.Test.TabPanelTest.client;


import com.extjs.gxt.ui.client.Style.LayoutRegion;

import com.extjs.gxt.ui.client.Style.Scroll;

import com.extjs.gxt.ui.client.event.ComponentEvent;

import com.extjs.gxt.ui.client.event.Events;

import com.extjs.gxt.ui.client.event.Listener;

import com.extjs.gxt.ui.client.event.TabPanelEvent;

import com.extjs.gxt.ui.client.mvc.Dispatcher;

import com.extjs.gxt.ui.client.util.Margins;

import com.extjs.gxt.ui.client.widget.ContentPanel;

import com.extjs.gxt.ui.client.widget.TabItem;

import com.extjs.gxt.ui.client.widget.TabPanel;

import com.extjs.gxt.ui.client.widget.Viewport;

import com.extjs.gxt.ui.client.widget.Window;

import com.extjs.gxt.ui.client.widget.TabPanel.TabPosition;

import com.extjs.gxt.ui.client.widget.layout.BorderLayout;

import com.extjs.gxt.ui.client.widget.layout.BorderLayoutData;

import com.extjs.gxt.ui.client.widget.layout.FitLayout;

import com.google.gwt.core.client.EntryPoint;

import com.google.gwt.core.client.GWT;

import com.google.gwt.event.dom.client.ClickEvent;

import com.google.gwt.event.dom.client.ClickHandler;

import com.google.gwt.event.dom.client.KeyCodes;

import com.google.gwt.event.dom.client.KeyUpEvent;

import com.google.gwt.event.dom.client.KeyUpHandler;

import com.google.gwt.http.client.RequestBuilder;

import com.google.gwt.user.client.History;

import com.google.gwt.user.client.rpc.AsyncCallback;

import com.google.gwt.user.client.ui.Button;

import com.google.gwt.user.client.ui.DialogBox;

import com.google.gwt.user.client.ui.HTML;

import com.google.gwt.user.client.ui.Label;

import com.google.gwt.user.client.ui.RootPanel;

import com.google.gwt.user.client.ui.TextBox;

import com.google.gwt.user.client.ui.VerticalPanel;


/**

*Entrypointclassesdefine<code>onModuleLoad()</code>.

*/

publicclass TabPanelTest implements EntryPoint {
/**

*Themessagedisplayedtotheuserwhentheservercannotbereachedor

*returnsanerror.

*/

privatestaticfinal String SERVER_ERROR = "An error occurred while "

+ "attempting to contact the server. Please check your network "

+ "connection and try again.";

/**

*Createaremoteserviceproxytotalktotheserver-sideGreetingservice.

*/

privatefinal GreetingServiceAsync greetingService = GWT
.create(GreetingService.class);

/**

*Thisistheentrypointmethod.

*/

publicvoid onModuleLoad() {
Viewport viewport = new Viewport();
viewport.setLayout(new BorderLayout());

ContentPanel cp = new ContentPanel();
cp.setBorders(false);
cp.setHeaderVisible(false);
cp.setLayout(new FitLayout());

String txt = "Test";
TabPanel folder = new TabPanel();
folder.setTabPosition(TabPosition.TOP);
folder.setCloseContextMenu(true);
folder.setBorderStyle(false);
folder.setBodyBorder(false);
folder.setTabScroll(true);
folder.setAnimScroll(true);
folder.addListener(Events.Remove, new Listener<TabPanelEvent>() {

publicvoid handleEvent(TabPanelEvent be) {
/*TabItem item = be.getItem();
Entry entry = (Entry) item.getData("entry");
Dispatcher.forwardEvent(AppEvents.HidePage, entry);*/

}

});
folder.addListener(Events.Select, new Listener<TabPanelEvent>() {
publicvoid handleEvent(TabPanelEvent be) {
/*String token = History.getToken();
Entry entry = (Entry) be.getItem().getData("entry");
if (token != null && (!token.equals(entry.getId()))) {
History.newItem(entry.getId(), false);
} */

}
});

TabItem shortText = new TabItem("Short Text");
shortText.addStyleName("pad-text");
shortText.addText(txt);
folder.add(shortText);

TabItem longText = new TabItem("Long Text");
longText.addStyleName("pad-text");
longText.addText(txt + "<br>" + txt);
folder.add(longText);

RootPanel.get().add(viewport);

BorderLayoutData data = new BorderLayoutData(LayoutRegion.CENTER);
data.setMargins(new Margins(5, 5, 5, 0));
viewport.add(cp, data);
cp.add(folder);
}
}

sven
8 Jul 2009, 7:02 AM
There is an issue in your code. You need to call viewport.layout(); as you alter your vieport. I amclosing this issue.