5.5.8. Web Client Specifics

Implementation of the generic user interface of the Web Client block is based on the Vaadin framework. The main classes available in the web client infrastructure are described below.

WebClientInfrastructure
Figure 22. Web Client Infrastructure Classes
  • App - the central class of the application infrastructure. Contains links to Connection and other infrastructure objects. Only one instance of App exists for a given HTTP session. You can get a reference to the App instance by using the App.getInstance() static method. If you want to customize functionality of App in your project, create a class extending DefaultApp in the root package of your web module and register it in web-spring.xml as the cuba_App bean, for example:

    <bean name="cuba_App" class="com.company.sample.web.MyApp" scope="prototype"/>
  • Connection is an interface providing functionality of connecting to middleware and holding a user session. DefaultConnection is a standard implementation of this interface.

  • ExceptionHandlers class contains a collection of client-level exception handlers.

  • AppUI is a platform class inherited from com.vaadin.ui.UI class. There is one instance of this class for each open tab of a web browser. Contains a link to a TopLevelWindow implementation – either a login window or main window, depending on the connection state. You can get a reference to the AppUI for the current browser tab by using the AppUI.getCurrent() static method.

  • AppLoginWindow – the window displayed before a user logs in. You can customize the login window by extending AppLoginWindow or create completely new one by extending AbstractWindow and implementing the TopLevelWindow marker interface. In Studio, go to the Screens section and click Create login window. If you override the init() method, make sure you invoke super.init(params).

  • AppMainWindow – main application window displayed after a user logs in. You can customize the main window by extending AppMainWindow or create completely new one by extending AbstractMainWindow and defining desired layout in XML descriptor. In Studio, go to the Screens section and click Create main window. If you override the init() method, make sure you invoke super.init(params).

    You can control certain main window parameters without redefinig the default implementation using the following application properties:

  • WindowManager - the central class implementing application screens management logic. openWindow(), openEditor(), showMessageDialog() and other methods of the Frame interface implemented by screen controllers delegate to the window manager. WindowManager class is located in the platform’s common gui module and is abstract. The web module has a dedicated WebWindowManager class that implements web client specifics. You can get a reference to WindowManager from any Window implementation (e.g. a screen controller), or via the WindowManagerProvider bean.

If you want to handle the browser Back button, implement the CubaHistoryControl.HistoryBackHandler interface in your TopLevelWindow (login and/or main windows). Its onHistoryBackPerformed() method is invoked instead of standard browser behavior if the cuba.web.allowHandleBrowserHistoryBack application property is set to true.