Vaadin 7 redirect on session expired

Hi all,

i’m trying to migrate an application from Vaadin 6 to Vaadin 7 and in the current application after a session timout the application automatically redirects to the login page without showing the system message dialog… I would like to preserve this behaviour in Vaadin 7, but could’n find a way to manage it… Is there a possibility ?

What I have tried was to set a custom SystemMessageProvider like


getService().setSystemMessagesProvider(new SystemMessagesProvider() {
			@Override
			public SystemMessages getSystemMessages(SystemMessagesInfo systemMessagesInfo) {
				CustomizedSystemMessages messages = new CustomizedSystemMessages();
				messages.setSessionExpiredURL(getServletContext().getContextPath());
				return messages;
			}
		});

This leads to a behaviour that the user has to perform some action on the ui (after session timout) to show the system message dialog where, after pressing on the dialog, the login page is shown… But this is not what i want.

Incredible that nobody can give an answer on this question even after 7 month not even one reply.

Can’t spend time looking myself, but this has been answered before, perhaps just not to your specific posting.

This is how we do it, using our class to override the VaadinServlet (so it needs to be configured in your web.xml or the like):

public class EsfVaadinServlet extends com.vaadin.server.VaadinServlet {

    @Override
    protected void servletInitialized() throws ServletException {
        super.servletInitialized();
        
        getService().setSystemMessagesProvider(
                new SystemMessagesProvider() {
                @Override
                public SystemMessages getSystemMessages(SystemMessagesInfo systemMessagesInfo) {
                    EsfVaadinUI ui = EsfVaadinUI.getInstance();
                    return ui == null ? new CustomizedSystemMessages() : ui.getCustomizedSystemMessages();
                }
               });
    }
...

And then our UI subclass has this:

    public CustomizedSystemMessages getCustomizedSystemMessages() {
        return customizedSystemMessages;
    }
    void setupCustomizedSystemMessages() {
        HttpSession sess = getHttpSession();
        customizedSystemMessages = new CustomizedSystemMessages();
        if (sess != null) {
            String url = getRequestExternalContextPath() + "/" + standardLogoutUrl + "?min="    + (sess.getMaxInactiveInterval() / 60);
            setLogoutURL(url);
            customizedSystemMessages.setSessionExpiredURL(url+"&t=to");
            customizedSystemMessages.setCommunicationErrorURL(url+"&t=to");
            customizedSystemMessages.setInternalErrorURL(url+"&t=err");
            customizedSystemMessages.setOutOfSyncURL(url+"&t=err");
            customizedSystemMessages.setCookiesDisabledURL(url+"&t=err");
        } else {
            setLogoutURL(getRequestExternalContextPath() + "/" + standardLogoutUrl + "?t=to");
        }
    }

People don’t look for questions 7 months old to answer them, so an old post typically only gets an answer if somebody stumbles upon it with a search, happens to know the answer and has the time to write it.

One shouldn’t expect an answer in a day or two (though sometimes one gets a quick answer), but posts older than two or three weeks are usually too far down the list for anybody to find them, and often the poster has found an answer or a workaround on his own by then (in which case posting it might help others).

If you need more predictable response times, you could consider
purchasing paid support
.

Thank you very much for your example… I will try it as soon as possible and provide feedback.