PDA

View Full Version : tabpanel and deferred render



fother
11 Aug 2009, 6:58 AM
my tabpanel its marked as deferred render equals false.. but I think that dont work..

example..
1 - click in the button "create tab".. will added a new tab.. click in text field dont type nothing.. click out of the field.. will mark as invalid..
2 - close the tab
3 - click in the button "create tab".. will added a new tab.. but the field continue marked as invalid..

my code its correct?

code example


public void onModuleLoad() {

final LayoutContainer container = new LayoutContainer();
container.setLayout(new FlowLayout(10));

final TextField<String> field = new TextField<String>();
field.setAllowBlank(false);

final FormPanel form = new FormPanel();
form.add(field);

final TabItem item = new TabItem();
item.setId("test");
item.add(form);
item.setText("test");
item.setClosable(true);

final TabPanel panel = new TabPanel();
panel.setSize(400, 400);
panel.setDeferredRender(false);

container.add(new Button("create tab", new SelectionListener<ButtonEvent>() {
@Override
public void componentSelected(final ButtonEvent ce) {

final TabItem xx = panel.findItem("test", false);

if (xx == null) {
panel.add(item);
}

}
}));
container.add(panel);

RootPanel.get().add(container);
}

mtarantini
11 Aug 2009, 7:25 AM
You say that the "Create Tab" create a new item ? But it seems to me that it does not.

You try to find the same panel everytime, but it's the same instance of the object each time, so it's normal that the field continue marked as invalid.

I think The event should be :



public void componentSelected(final ButtonEvent ce) {

TabItem item = new TabItem();
item.setId("test"+panel.getItemCount());
item.add(form);
item.setText("test");
item.setClosable(true);

panel.add(item);
}