Programatically showing different screens

I have a couple of questions on moving between different screens.

  1. In your Dashboard example, you only implement the dashboard page. Say I wanted to implement a page for one of the other buttons (e.g. settings), how would I enable it to switch to a settings page and then go back to the dashboard when you hit the dashboard button on the left menu?

  2. This is a follow up to Public faced web site user registration - CUBA.Platform
    Say I’ve changed the login page to be my home page for anonymous users. When they hit a login link, how do I get the screen to switch to the login page which asks for username and password?

You can easily open new screens in DIALOG mode as demonstrated in the User Registration example. But in order to open screens in tabs as in standard main window, you should place the WorkArea component to your main or login window. Then when you use NEW_TAB or THIS_TAB modes, the screens will open inside the work area.

A main window switching between Dashboard and normal screens flow can be implemented as follows:

  • Add a root VBox to your main window.

  • Add two VBoxes to the root, both with 100% height.

  • Make one of VBoxes visible, the other invisible.

  • Place a dashboard to the first VBox, the WorkArea to the second.

  • When you need to open a screen from Dashboard, switch visibility of VBoxes and open the screen in NEW_TAB.

  • Add a StateChangeListener to WorkArea and when the state becomes INITIAL_LAYOUT (no open screens), switch the visibility of VBoxes back to show the Dashboard.

The same can be done in login window for anonymous access.

How would it work if you want the menu at left to be visible at all times and just the panel on the right to change, showing the dashboard or whatever other functionality the other buttons on the menu reveal?

Well, add HBox or SplitPanel as the very root layout. Place the menu to the left and the root VBox mentioned above to the right.

I’m having a problem getting the WorkArea to open to my initial screen. I have a ExtAppMainWindow which extends AbstractMainWindow.

I’m injecting the AppWorkArea. In the init() method the work area is set and I can add a StateChangeListener which works. However, when the work area gets to the init() method, it is already in INITIAL_LAYOUT state. If I do an openWindow with NEW_TAB in init(), I get an “IllegalStateException: Application does not have any configured work area”.

Where in the lifecycle should I do the openWindow? Alternately, how can I determine when the work area is configured and then set it before it is displayed?

Hi,

you can open new Windows either from ready life cycle method or after full window initialization from UI event handlers.

Thx. The ready method worked well. How do you access the UI event handlers?