PDA

View Full Version : Two tab panel in a FormPanel



Sudha1807
21 Oct 2011, 6:29 AM
Hi,

In a FormPanel I included two TabPanles and gave activeTab as zero for both the panel but having problem to view first panel. How to activate zero tab on both the panels?


Thank You

WesleyMoy
8 Nov 2011, 2:32 PM
What specifically are you having problems with? I don't have any problems placing two TabPanels in a FormPanel.

In general, to select the first tab, use tabPanel.setSelection(tabPanel.getItem(0)). Here's a short code example I wrote to test for your problem.



public class TabPanelMan implements EntryPoint {

/**
* Creates a tab item containing a single button. The item and the button are
* labelled with the provided integer.
*
* @param a The integer use in the label
* @return The constructed tab item
*/
private static TabItem createTabItem(int a) {
TabItem item = new TabItem("Item " + a);
item.add(new Button("Button " + a));
return item;
}

@Override
public void onModuleLoad() {
// Create the form panel
FormPanel form = new FormPanel();

// Create the first tab panel and five tabs
final TabPanel tabPanelTop = new TabPanel();
tabPanelTop.setAutoHeight(true);
for (int i = 0; i < 5; i++)
tabPanelTop.add(createTabItem(i));

// Add it to the form
form.add(tabPanelTop);

// Create the second tab panel and five tabs
TabPanel tabPanelBottom = new TabPanel();
tabPanelBottom.setAutoHeight(true);
for (int i = 5; i < 10; i++)
tabPanelBottom.add(createTabItem(i));

// Add it to the form
form.add(tabPanelBottom);

// Add the form to the page
RootPanel.get().add(form);

// Also add a button that selects the first tab
RootPanel.get().add(new Button("Select Item 0", new SelectionListener<ButtonEvent>() {

@Override
public void componentSelected(ButtonEvent ce) {
tabPanelTop.setSelection(tabPanelTop.getItem(0));
}

}));
}

}


If you're still having problems, post a short code sample showing what the problem is, or go into some more detail about what exactly isn't rendering properly.

The_Jackal
8 Nov 2011, 3:23 PM
Not sure if this is related to your issue, but I found a quirk with tabs on a form; validation will not check tabs that have not been clicked on. This is due the default deferred rendering. To have validation check all tabs set deferredRender to false:


TabPanel tabs = new TabPanel();
tabs.setDeferredRender(false)