The intial situtation is as shown in the picture below. I have a main UI that creates a dialog. In this dialog some attributes are generated. I want to transfer the attributes to the main UI on button click and close the dialog afterwards. Then i want to refresh the UI, so that the UI gets updated with the new attributes/parameters.
Closing the dialog works like this:
this.getParent().ifPresent(parent -> {
if(parent instanceof Dialog)
{
((Dialog)parent).close();
}
});
But right now i have no clue how to transfer the attributes to the main UI and refresh it afterwards.
For better imagination i will explain a use case. In the dialog i get a certain number (´int i = 2`). In the UI there is a method that creates tabs. I want as many tabs as i says. So i need to declare i in the UI class in order to execute the method successfully.
Code that creates the tabs: Contructor (MainView):
final Tabs tabs = this.createTabs();
this.add(this.div, tabs);
tabs.addSelectedChangeListener(e -> {
this.div.removeAll();
this.div.add(this.tabComponentMap.get(e.getSelectedTab()));
});
this.div.add(this.tabComponentMap.get(tabs.getSelectedTab()));
Method create tabs:
private Tabs createTabs()
{
for(int i = 0; i <= h; i++)
{
if(i == 0)
{
this.tabComponentMap.put(new Tab("Tab" + i), new SubView1());
}
else
{
this.tabComponentMap.put(new Tab("Tab" + i), new SubView2());
}
}
return new Tabs(this.tabComponentMap.keySet().toArray(new Tab[]{}));
}
h is the attribute that i get from the dialog.