I am wondering how can I include in the main page other regions where I can open screens other than browser or editors.
I would like to create plain Screen instances where I manually display other types of non editable information such as accessory tables, charts or other type of knfo that I load directly after “showing” the screen.
After analyzing the extmainscreen file in the default project template I see all the screens created in Cuba are displayed in the workArea tag. My question is, is it possible to create other areas where I can place other screens and if so… where do I specify the workArea the given screen should be placed into.
Inject customPanel vertical layout into screen controller and add getter:
@UiController("extMainScreen")
@UiDescriptor("ext-main-screen.xml")
public class ExtMainScreen extends MainScreen {
@Inject
protected VBoxLayout customPanel;
public VBoxLayout getCustomPanel() {
return customPanel;
}
}
Let’s create helper bean in the web module that will accept a screen to show:
@Component("app_ScreenPlacementHelper")
public class ScreenPlacementHelper {
public void showScreen(Screen screen) {
// Get a reference to extended main screen
ExtMainScreen extMainScreen = (ExtMainScreen) UiControllerUtils
.getScreen(AppUI.getCurrent().getTopLevelWindowNN().getFrameOwner());
VBoxLayout customPanel = extMainScreen.getCustomPanel();
// Remove old content
customPanel.removeAll();
// Add new content
customPanel.add(screen.getWindow());
}
}