Session Timeout URL

I’m sorry to ask this ‘simple’ Question, but i couldn’t find anything about this topic which includes a easy solution.

I’m new in vaadin and i’d like to set the URL/View where to go on ->Click here<- for the Session Timeout Systemmessage.
Is there an easy solution? like → getSystemMessages(SESSION_TIMEOUT).setURL(“Url”);

Hint I’m using Vaadin 7 and UI and Views, no VaadinServlets.

Greetings and enjoy your day!

The SystemMessages class has no setters, so you need to define your own SystemMessagesProvider that returns a CustomizedSystemMessages object, as described
here
.

You need to extend VaadinServlet in order to configure that in the servletInitialized() method.

Thx for the reply. I found the section in the book, but I thought there might be a simpler solution.

So I have to create a Servlet in my Application and call it from my UI just to initialize the System Messages. Am I Correct?
My Application is so small, I thought I just call the UI and make some Views and → boom im ready :frowning:

In Vaadin 7 you have to create your own Custom Servlet and then include it in your web.xml (no need to call it from your UI as far as I know).
The Servlet is very simple to create. In your case it can be as easy as that:

public class MyCustomServlet extends VaadinServlet {
	private static final long serialVersionUID = 1L;
	
	@Override
    protected void servletInitialized()
            throws ServletException {
    	getService().setSystemMessagesProvider(
    		    new SystemMessagesProvider() {
					private static final long serialVersionUID = 1L;

				@Override 
    		    public SystemMessages getSystemMessages(
    		        SystemMessagesInfo systemMessagesInfo) {
    		        CustomizedSystemMessages messages =
    		                new CustomizedSystemMessages();
    		        messages.setSessionExpired....
    		        return messages;
    		    }
    		});
        super.servletInitialized();

    }
}

And nowadays our recommendation is to use the @WebServlet+@VaadinServletConfiguration annotations for a servlet class instead of web.xml. That’s for servers that support Servlet 3.0, as most nowadays do. So you always have a custom servlet class.

Thx guys, you are great !

Hey again,

only for Information:
If you are using Spring & Vaadin and the Spring-Vaadin AddOn
https://vaadin.com/directory#addon/springvaadinintegration
you don’t need a Servlet.
I implemented my Class for changing myself. Like


public class SystemMessagesChanger implements SpringSystemMessagesProvider {

	private static final long serialVersionUID = -2526778572119281281L;

	@Override
	public SystemMessages getSystemMessages(Locale arg0) {

		CustomizedSystemMessages systemMessages = new CustomizedSystemMessages();
		String message;
		systemMessages.setSessionExpiredCaption("");
		systemMessages.setSessionExpiredMessage("");
		systemMessages.setSessionExpiredURL("");
		systemMessages.setSessionExpiredNotificationEnabled(true);
		return systemMessages;
	}

and the web.xml like


    <servlet>
        <servlet-name>MainController</servlet-name>
        <servlet-class>ru.xpoft.vaadin.SpringVaadinServlet</servlet-class>
        <init-param>
            <param-name>beanName</param-name>
            <param-value>MainController</param-value>
        </init-param>
        <init-param>
        	<param-name>systemMessagesBeanName</param-name>
        	<param-value>SystemMessagesChanger</param-value>
    	</init-param>
    </servlet>

Works fine for me :wink:
Now we have some fine solutions i think.