Last Updated: February 25, 2016
·
3.594K
· bripkens

Custom Vaadin Session Timeout Handler

Override the com.vaadin.Application#getSystemMessages() method to add custom functionality.

public class CustomApplication extends com.vaadin.Application {

    @Overrides
    public static SystemMessages getSystemMessages() {
        CustomizedSystemMessages msgs;
        msgs = new CustomizedSystemMessages();
        msgs.setSessionExpiredNotificationEnabled(false);
        msgs.setSessionExpiredURL("javascript:handleSessionTimeout();");
        return msgs;
    }

}

On the client side, you can now use JavaScript and respond to this event:

function handleSessionTimeout() {
    console.log("Foo - the session timed out!");
};