Anonymous Access to Screens

By default, only the login screen is available to the anonymous (not authenticated) session. By creating the new login screen, you can add any information on it or even add the WorkArea component and be able to open inside it other screens available to the anonymous user. But as soon as the user logs in, all screens opened in the anonymous mode will be closed.

Sometimes it is necessary to provide some application screens regardless of whether the user is authenticated in the system or not. Consider the following requirements:

  • When users open the application, they see the main screen with the side menu available for anonymous users.

  • There is an Info screen with some publicly available information. By clicking the Show the Login Screen button, users can go to the login screen and continue working with the rest of the system as authenticated users.

  • Users can open the Info screen both from the main menu and by entering a URL in the web browser.

Implementation steps are described below.

  1. Create the new main screen using the Main screen with side menu template.

  2. Create your screen, for example, MyAnonymousScreen, with some information for anonymous users and a button that opens the login screen:

    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <window xmlns=""
            <vbox spacing="true">
                <label value="Some information for anonymous users" stylename="h1"/>
                <button id="showLoginScreenBtn" caption="Show the Login Screen"/>

    Annotate the controller with @Route to be able to open it using a link:
    @Route(path = "anonymous") (1)
    public class MyAnonymousScreen extends Screen {
        private Screens screens;
        private UiProperties uiProperties;
        protected void onShowLoginScreenBtnClick(Button.ClickEvent event) {
            String loginScreenId = uiProperties.getLoginScreenId();
            Screen loginScreen = screens.create(loginScreenId, OpenMode.ROOT);
    1 Specifies the screen’s address. When the screen is opened in the top-level window (as root), its address will be http://localhost:8080/#anonymous.
  3. Define the new menu item under the Application menu:

    <item id="anonymousScreen"
  4. Create the AnonymousRole resource role and allow access to MyAnonymousScreen and MainScreenSideMenu:

    @ResourceRole(name = "AnonymousRole", code = AnonymousRole.CODE)
    public interface AnonymousRole {
        String CODE = "anonymous-role";
        @MenuPolicy(menuIds = {"anonymousScreen"})
        @ScreenPolicy(screenIds = {"MainScreenSideMenu", "MyAnonymousScreen"})
        void screens();
        @MenuPolicy(menuIds = {"application"})
        void commonMenus();
  5. Grant AnonymousRole to the anonymous user in DatabaseUserRepository:

    protected void initAnonymousUser(User anonymousUser) {
        Collection<GrantedAuthority> authorities = getGrantedAuthoritiesBuilder()
  6. In the file enable anonymous access and specify which screen appears for the anonymous user:

    # enable anonymous access
    # initial screen for anonymous user

    Keep in mind that you’ll have two main screens in your app. The default one will be used for authenticated users and the anonymous one for anonymous:

  7. Launch the application and make sure that the screen you created opens from the main menu and at /#anonymous.