Browser page reload notification.

My question is:

I’ve asked it long ago, but got no “ready to use” answer.

http://vaadin.com/forum/-/message_boards/message/45510#_19_message_52270

Michael Nash suggests adding a mechanism like GWT History.

http://vaadin.com/forum/-/message_boards/message/45510#_19_message_131744

In 2011, a user presses F5 on a (Vaadin) web site page and sees no change (gets the old widgets from the HttpSession) !?
It’s a very bad detail that would make people notice “that web site is probably powered by Vaadin”, which is probably not what you want (in that negative direction I mean).

Sorry to be that hard :wink:

Hi,

I had a similar problem. I was looking for a way to open a resource (download a file) without opening a new window. Downloading a file to the same window changes the current window location and closes the application. I used a hidden Embedded component. I just set size to 0x0, type to TYPE_BROWSER, resource mime type to “application/octect-stream” and then load the resource into the Embedded to force the browser to donwload the file.
This is useful to silent print a PDF adding the script “this.print({bUI: false,bSilent: true});” to the PDF file, setting mime type to “application/pdf” and then loading the pdf file into the embedded.

I just wanted to avoid a re-download or re-print of a resource loaded into the Embedded when the user uses the refresh browser button, so i face the same problem: how to listen for refreshes to clear the Embedded.

I used this code to do that:

    WebApplicationContext wac=(WebApplicationContext) this.getContext();
    wac.addTransactionListener(new TransactionListener()
    {
      @Override
      public void transactionStart(Application application, Object transactionData)
      {
        if(request.getRequestURI().lastIndexOf("/")==0)
          downloader.setSource(new ExternalResource("about:blank"));
      }
      
      @Override
      public void transactionEnd(Application application, Object transactionData)
      {
      }
    });

I noted that vaadin internal calls use urls like “/AppName/UIDL” and resource calls use urls like “/AppName/APP/xxxxx”. However refresh urls are just a plain “/AppName”. So if the last index of “/” is 0, then the user is refreshing the page.

I didn’t test it enough but It seems to work fine.

Please post your comments if you can test it (two developers test better than one).