StreamResource and IE

Hi,

i have some trouble with opening a StreamResource. In the past, i was just using getApplication().getMainWindow().open(myStreamResource) after hitting a button on which the myStreamResource was generated.

However, just now, i’ve implemented a progress bar to indicate to the user how long it is going to take to generate the myStreamResource. So i start 2 new threads when hitting the ‘download’ button in my Vaadin app; 1 thread that updates the progress bar and 1 that generates the myStreamResource. This last thread then also invokes the getApplication().getMainWindow().open(myStreamResource) method.

This gives issues with Vaadin as i see the red ‘Communication Problem’ message when the myStreamResource is ready to download. I’m able to download the content, and after clicking ‘continue’ on the Communication Problem dialog, the GUI continues, but it is annoying for the user.

Apparently this happens because i open the StreamResource in the same window and that window is being painted at that moment because of the progress bar.

So what i tried, is using getApplication().getMainWindow().open(myStreamResource,“_blank”). This runs without problem on Firefox and Chrome, but in Internet Explorer, it gives me a very quick popup which then disappears immediately without giving the possibility to download the content.

Any suggestion on how i could fix this for IE?

p.s. Some more information on what the myStreamResource contains:
myStreamResource is an object of the following class:


public class DownloadResource extends StreamResource {

    private final String filename;

    public DownloadResource(File fileToDownload, Application application)
            throws FileNotFoundException {
        super(new FileStreamResource(fileToDownload), fileToDownload.getName(),
                application);

        this.filename = fileToDownload.getName();
        this.setCacheTime(5 * 1000);
        this.setMIMEType("application/octet-stream");
    }

    @Override
    public DownloadStream getStream() {
        DownloadStream stream = new DownloadStream(getStreamSource()
                .getStream(), "application/octet-stream", filename);
        stream.setParameter("Content-Disposition", "attachment; filename=\""
                + filename + "\"");
        return stream;
    }

    private static class FileStreamResource implements
            StreamResource.StreamSource {

        private final InputStream inputStream;

        public FileStreamResource(File fileToDownload)
                throws FileNotFoundException {
            inputStream = new FileInputStream(fileToDownload);
        }

        @Override
        public InputStream getStream() {
            return inputStream;
        }
    }
}

Isn’t there anyone who has seen the same issue here?

Come on guys, i’m really stuck here…
Somebody must have had the same issue…

I have a similar Problem. When downloading a file in Chrome, I get the red “Communication Problem” error, even the file can be downloaded. This hasn’t happend yet in IE or FF.

I can’t reproduce it in a sample application. Do you use the Refresher?

Regarding the disappearing IE-Popup, I guess this bug addresses your problem
http://dev.vaadin.com/ticket/3366

The “Communication Problem”, as i already said, is due to the fact that you are changing the layout from within 2 different threads: 1 thread that updates the progress bar and 1 thread that tries to open the content that should be downloaded.

I don’t use the Refresher, but the progress bar is similar (updates every … ms)

Should have read more carefully, thanks :slight_smile: I’ll check my synchronization.