Search code examples
vaadinvaadin7

Vaadin Change the default Session Expired Notification?


Vaadin 7.6.2

How to change the default Session Expired Notification; both the message and the type of notification?


Solution

  • To change session expired message you need to create your own SystemMessagesProvider, where you define it. For example in a servlet deployment, you could do the following:

    @WebServlet(urlPatterns = "/*", name = "MyUIServlet", asyncSupported = true)
    @VaadinServletConfiguration(ui = MyUI.class, productionMode = false)
    public static class MyUIServlet extends VaadinServlet {
    
        @Override
        protected void servletInitialized() throws ServletException {
            super.servletInitialized();
    
            CustomizedSystemMessages messages = new CustomizedSystemMessages();
            messages.setSessionExpiredCaption("Session expired caption");
            messages.setSessionExpiredMessage("Session expired more detailed message");
    
            getService().setSystemMessagesProvider(e -> messages);
    
        }
    }
    

    There is no a built-in way to change the type of notification. Of course you can style it with css, but the styling affects to other system notifications as well.