I have a GWT tab panel and would like to reload a single tab when a certain event (e.g. button click) happens in another tab. Is there a way to do that? Another possibility would be executing some code (e.g. adding a new element to a tab) when that tab is selected. Any help would be really appreciated, I am stuck with this for a while already.
To make the question more specific I am providing some code below.
I have my code organized in screens, there is a home screen that initiates the tab panel. And there are separate screens for initiation of each tab.
The simplified code for the home screen:
public class HomeScreen extends Composite{
public HomeScreen() {
TabPanel tabPanel = new TabPanel();
FlowPanel flowpanel;
flowpanel = new FlowPanel();
ProfileTabScreen profileTabScreen = new ProfileTabScreen();
flowpanel.add(profileTabScreen);
tabPanel.add(flowpanel, "Profile");
flowpanel = new FlowPanel();
GroupsTabScreen groupsTabScreen = new GroupsTabScreen();
flowpanel.add(groupsTabScreen);
tabPanel.add(flowpanel, "Groups");
initWidget(tabPanel);
}
}
Code for the tab screen from which I want to initiate the reload:
private VerticalPanel groupPanel = new VerticalPanel();
private Button newGroupButton = new Button("New group");
public GroupsTabScreen() {
newGroupButton.addClickHandler(new ClickHandler(){
public void onClick(ClickEvent event) {
createNewGroup();
}
});
groupPanel.add(newGroupButton);
initWidget(groupPanel);
}
Code for the tab screen that has to be reloaded:
private VerticalPanel profilePanel = new VerticalPanel();
private Label label = new Label("No groups yet.");
public ProfileTabScreen() {
profilePanel.add(label);
initWidget(profilePanel);
}
So let's imagine I just want to change text of a label in profileTab (while in reality it will be ListBox and other elements), when the newGroupButton is clicked in groupTab.
As I said, reloading the whole profileTab each time is is selected would be acceptable as well.