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?
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; }”);
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;
}
});
}
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.