I want to implement a solution, that behaves like a single page application. My app has a top menu, and I customized the application with cuba.web.appWindowMode = SINGLE. Furthermore I changed the CSS to remove the close button of the screens.
But whenever the user selects the menu item to show the main screen, a new instance is created and shown. I want to implement, that only one screen instance exists and when the user selects the corresponding menu itemn, the already loaded instance will be shown (like it is done when the user uses the explorer back-button)
I tried the following code: but it does not take the existing instance into the foreground:
AppMenu.MenuItem suchMenu = mainMenu.getMenuItem("menuItemSearch");
suchMenu.setCommand(commad -> {
Screens.OpenedScreens screensOpened = screens.getOpenedScreens();
Collection<Screen> workAreaScreesn = screensOpened.getActiveWorkAreaScreens();
if( workAreaScreens != null ) {
for( Screen screen : workAreaScreens ) {
if( screen instanceof Objectbrowser ) {
screens.showFromNavigation(screen);
}
}
}
else {
screens.create(Objectbrowser.class).show();
}
});