2 Replies Latest reply on Feb 16, 2010 4:16 PM by someblue

    File download with immediate save-as dialog

      My application offers download of large files (>10M). I perfectly managed to show the save-as dialog to save the file (with a a4j:htmlCommandLink). The problem is that the dialog appears only when the file is completly transferred to the client; thus, the client does not realise that the download really startet.

       

      I can't set a Content-Length header, because the data is zipped on the fly, and the file size is not known. I tried to send it in chunks and flush the buffer between, but this has only an effect in firefox. In ie, the dialog still appears at the end of the session.

       

      Any other idea? Is there a possibility to show a loading indicator (ok, this I can already do...), and to remove the indicator after download completion (...don't know how to do that.)??

       

      Regards,

      Ray

        • 1. Re: File download with immediate save-as dialog
          nbelaevski

          Hi Ray,

           

          I guess it's the same problem as here: https://jira.jboss.org/jira/browse/RF-7019 . Can you try using servlet as workaround? 

          • 2. Re: File download with immediate save-as dialog

            My solution is technically working, i.e. the file gets downloaded. The problem is that the user does not have an immediate response that the download is going on.

             

            Some investigation showed that without a Content-Length header, internet explorer does not show the save-as dialog immediately; with or without servlet. So, I'm back on trying to show a loading indicator. I can start the loading indicator when the user clicks on the a4j:htmlCommandLink. However, I don't know how to stop it, because with the start of the download, the JSF cycle gets terminated.

             

            Maybe I could start an a4j:poll, which checks on the server if a download-finished flag is set. A bit complicated, though...