Page.getCurrent().setLocation("/app/#!/");
ApplicationSession.getCurrent().close();
Works in firefox (26 version). Chrome (Version 28.0.1500.71) do not redirect to location
I have built an application using vaadin 7. i am trying to automatically forward the user to logon screen once the session has expired. I see lot of examples for vaadin 6 but i don’t have any clue about vaadin 7. I tried the above said but it does not work as expected.It does not forward the user to any other page. Can you please give me the steps (configuration and code) to implement this feature. btw what is this push enabled mean?
If you wont to see session expired message, you can disable it. It useful when you need to invalidate session.
VaadinService.getCurrent().setSystemMessagesProvider(new SystemMessagesProvider() {
@Override
public SystemMessages getSystemMessages(SystemMessagesInfo systemMessagesInfo) {
CustomizedSystemMessages customizedSystemMessages = new CustomizedSystemMessages();
customizedSystemMessages.setSessionExpiredNotificationEnabled(false);
return customizedSystemMessages;
}
});
After invalidate session u can redirect your client to any location.
Or you can set expire url. I think vaadin automaticly does redirect depends on SessionExpiredURL.
VaadinService.getCurrent().setSystemMessagesProvider(new SystemMessagesProvider() {
@Override
public SystemMessages getSystemMessages(SystemMessagesInfo systemMessagesInfo) {
CustomizedSystemMessages customizedSystemMessages = new
[b]
customizedSystemMessages.setSessionExpiredURL("LOCATION");
[/b]
return customizedSystemMessages;
}
});
I tried your idea of using setSystemMessagesProvider to automatically redirect the user to logon page once the session expired. it did not work either.
I am not sure if i am missing something. The vaadin life cycle understands that the session has expired but it does not take any action like redirect to logon until the user click on any vaadin component. Hope you are clear with my question now.
If you do not use push then the server has no way of telling the client that something has happened. There is a special case in the framework which sets a timer on the browser side depending on the configured session timeout on the server so it can redirect automatically without user interaction or push. This seems to be used only in the case that session expired is configured (using SystemMessages) so that the message is null, the caption is null, notification is enabled and an url has been set. In this case there should be a redirect in the browser automatically after the session has expired (within 15 seconds based on the code).
Thanks for explaining it for me. Is there is pre-requiste to make push work? if i enable push it reports as given below. Will it work only in Java 1.7 or any specific version of servlet?
java.lang.IllegalStateException: Not supported.
at org.apache.catalina.connector.Request.startAsync(Request.java:1609)
at org.apache.catalina.connector.RequestFacade.startAsync(RequestFacade.java:1031)
at javax.servlet.ServletRequestWrapper.startAsync(ServletRequestWrapper.java:379)
at org.atmosphere.cpr.AtmosphereRequest.startAsync(AtmosphereRequest.java:565)
at org.atmosphere.container.Servlet30CometSupport.suspend(Servlet30CometSupport.java:137)
at org.atmosphere.container.Servlet30CometSupport.service(Servlet30CometSupport.java:103)
at org.atmosphere.cpr.AtmosphereFramework.doCometSupport(AtmosphereFramework.java:1464)
at com.vaadin.server.communication.PushRequestHandler.handleRequest(PushRequestHandler.java:121)
at com.vaadin.server.VaadinService.handleRequest(VaadinService.java:1382)
at com.vaadin.server.VaadinServlet.service(VaadinServlet.java:238)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)