I start developping an interface with GWT using MVP architecture according to this model:
- A first view that instantiates a TabLayoutPanel, defines the first Tab's widgets and an empty second Tab.
- onSelection of the second Tab I fire an event that sends the whole TabLayoutPanel to a second view that will define the second Tab's widgets.
On the second view I recieve the appropriate TabLayoutPanel but when I retrieve the second Tab, make changes and insert it in the old panel I got the message "This widget's parent does not implement HasWidgets" and the second Tab disappears.
Thanks for helpping me to see what is the true problem here or how to do it otherwise.
I added the second view code with comments.
public class MDP2View extends Composite implements MDP2Presenter.Display {
private final TabLayoutPanel tabPanel;
private final VerticalPanel MDP2;
private final Label label;
public MDP2View(HasSelectionHandlers<Integer> tabPanel) {
// Getting the TabLayoutPanel created on the first View
this.tabPanel = (TabLayoutPanel) tabPanel;
// Getting the second Tab (this will remove the Tab from the TabLayoutPanel)
MDP2 = (VerticalPanel) this.tabPanel.getWidget(1);
initWidget(MDP2);
// Adding a label to the Tab
label = new Label();
label.setText("onSelectionHandler Works!!!");
MDP2.add(label);
// Inserting the Tab in the tabPanel
this.tabPanel.insert(MDP2, "MDP2", 1);
}