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.
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
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.