Window.CloseEvent from browser window/tab


I’m trying to capture a Window.CloseEvent when a browser window or tab is closed that was opened from the main application using BrowserWindowOpener.

Here’s the code that generates a link that opens a new browser tab/window when clicked:

    pocnTable.addGeneratedColumn("button", new CustomTable.ColumnGenerator() {
        public Object generateCell(CustomTable customTable, Object itemId, Object columnId) {
            PocnData pd = PocnDao.load(new Integer(itemId.toString()));

            Link open = new Link("Open", new ExternalResource(Page.getCurrent().getLocation().toASCIIString() + pd.getPocnNumber()));

            BrowserWindowOpener popupOpener = new BrowserWindowOpener(PocnUI.class);


            return open;
This woks perfectly but I need to catch the event when this new browser window/tab is closed to release access to this record.

Each window is generated from a Servlet. Here is the code that is used when opening the new window/tab, I have added the Window.CloseListener implementation and added the windowClose event handler, but it never fires.

@WebServlet(urlPatterns = "/*", name = "PocnUIServlet", asyncSupported = true)
@VaadinServletConfiguration(ui = PocnUI.class, productionMode = false)
public static class PocnUIServlet extends VaadinServlet implements SessionInitListener, SessionDestroyListener, Window.CloseListener {

    private static final long serialVersionUID = 1L;

    public void windowClose(Window.CloseEvent e) {
                .withCaption("Window Closing");
        System.out.println("I wus closed!");

    protected void servletInitialized() throws ServletException {

    public void sessionInit(SessionInitEvent event)
            throws ServiceException {
        // Do session start stuff here

    public void sessionDestroy(SessionDestroyEvent event) {
        // Do session end stuff here


I don't think this is in the right place but I'm not sure where to implement the Window.CloseListener.
Any help is appreciated and I can include more code if needed.