VaadinServlet and TouchKitServlet with @PreserveOnRefresh

Hi, I’m starting to use this framework and I noticed that with @PreserveOnRefresh notation in an application with VaadinServlet if I close (or not) the tab and go to the same address from another tab UI is recreated.
In an application with TouchKitServlet and @PreserveOnRefresh notation if I do the same actions I get the same UI of closed tab in new tab.

How can I get the same result with the VaadinServlet? online book chapter?
Thanks.

I find in touchkit source what provides this feature. This is the code that I have ported to a simple VaadinServlet:


package com.example.demoui;

import javax.servlet.ServletException;

import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;

import com.vaadin.annotations.PreserveOnRefresh;
import com.vaadin.server.BootstrapFragmentResponse;
import com.vaadin.server.BootstrapListener;
import com.vaadin.server.BootstrapPageResponse;
import com.vaadin.server.SessionInitEvent;
import com.vaadin.server.SessionInitListener;
import com.vaadin.server.VaadinServlet;

/**
 * Servlet implementation class ServletProva
 */
public class ServletConfig extends VaadinServlet {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	protected void servletInitialized() throws ServletException {
		super.servletInitialized();
		getService().addSessionInitListener(new SessionInitListener() {

			private static final long serialVersionUID = -7450528266754788830L;

			public void sessionInit(SessionInitEvent event) {
				event.getSession().addBootstrapListener(new BootstrapListener() {

					/**
					 * 
					 */
					private static final long serialVersionUID = 7553693042995782446L;


   					/*
 					      * Ensure window has "stable name", in case PreserveOnRefresh is used.
 					      * This is to fool vaadinBootstrap.js so that for example applications
 					      * used as ios "home screen webapps", can preserve their state among app
 					      * switches, like following links (with browser) and then returning back
					      * to app.
 					*/
					@Override
					public void modifyBootstrapPage(BootstrapPageResponse response) {
						
				        Document document = response.getDocument();

				        Element head = document.getElementsByTag("head").get(0);

				        Element element;
				        
				        if (response.getUiClass().getAnnotation(PreserveOnRefresh.class) != null) {
				            element = document.createElement("script");
				            element.attr("type", "text/javascript");
				            element.appendText("\nwindow.name = '"
				                    + response.getUiClass().hashCode() + "';\n");
				            head.appendChild(element);
				        }
						
			
					}

					@Override
					public void modifyBootstrapFragment(BootstrapFragmentResponse response) {
						
						
					}
				});
			}
		});
	}
}