Session expired message when logging out

I have Push enabled in my application, mostly using it to inform all browser tabs that the session is closed if we are logging out from one of the tabs.
This works very well, but the problem is that I can see the session expired message in the tab from when I’m logging out before there’s time to redirect to the login page (a second). That is ugly and confusing for the users.

Is there a way to disable the system notifications just for certain cases? Do I have to logout in an another way?

This is how I logout:

MyVaadinUI.getCurrent().getSession().close();
Page.getCurrent().setLocation("");

Hi,

just swap the lines:

set the location first and then close the session.

Page.getCurrent().setLocation("");
MyVaadinUI.getCurrent().getSession().close();

this should work

Yeah, I tried that, but the UI doesn’t get changed before the session is closed. Even sleeping ten seconds between operations I still can see the notification for some milliseconds before it redirects to the login page.

It’s not really clear why you are getting this, but without going into details you can temporarily hide the message by using this line (add before closing the session):
Page.getCurrent().getStyles().add(“.v-Notification-system { visibility: hidden !important; }”);

Shouldn’t cause any problems.

That’s a smart way of hiding it, thank you.
I will use this solution for the moment and try to find what is causing the problem with calm.
Thanks!

after reading your first post again i recognized, that you open different tabs of the same UI.
so every UI runs in the same session. closing the session in one UI and redirecting to an other page brings that error message up.

my solutiion that i have tried so far, would look like this:

in your UI class:

private void setupMessageProvider(VaadinRequest request) {
        request.getService().setSystemMessagesProvider(
                new SystemMessagesProvider() {
                    @Override
                    public SystemMessages getSystemMessages(
                            SystemMessagesInfo systemMessagesInfo) {
                        CustomizedSystemMessages msgs = new CustomizedSystemMessages();
                        msgs.setSessionExpiredMessage(null);
                        msgs.setSessionExpiredCaption(null);
                        msgs.setSessionExpiredNotificationEnabled(true);
                        msgs.setSessionExpiredURL("http://example.com/");
                        return msgs;
                    }
                });
    }

complete example was found on

https://github.com/vaadin/vaadin/blob/master/uitest/src/com/vaadin/tests/components/ui/TimeoutRedirectResetsOnActivity.java

Yours is an interesting solution, but the problem is that this will remove the messages from all the UIs and I just want to remove it from the UI in which I pressed the Logout button. I need the users to know that the session is expired in the other tabs so they can for example copy the info they had in a form. If they don’t know that the session is expired they will commit and lose all the work.

why dont you present a meaningful message within a logout dialog?
so the user is aware of the fact that any unsaved data would be lost.

but if you need a session timeout message with a special hint for the user, set the message here:

request.getService().setSystemMessagesProvider(
new SystemMessagesProvider() {
@Override
public SystemMessages getSystemMessages(
SystemMessagesInfo systemMessagesInfo) {
CustomizedSystemMessages msgs = new CustomizedSystemMessages();
msgs.setSessionExpiredMessage(“your message”);
msgs.setSessionExpiredCaption(“Atention please!”
msgs.setSessionExpiredNotificationEnabled(true);
msgs.setSessionExpiredURL(null);
return msgs;
}
});