We have a curious problem in our JSF application that did not appear in
an equivalent Struts application: When we write contents to the response
to be downloaded to the client (e.g., a comma-delimited .csv file), the
browser pop-up that asks the user whether the user wants to "open" or
"save" the file appears a second time after the user chooses "open."
Thus, the user has to click on the "open" button twice to open the
downloaded file.

A description of the problem (along with a workaround) is at
http://www.rpmsoftware.com/wiki/index.php/Download_asks_twice

The work-around given in the description requires the user to modify
his/her settings, which is unacceptable for our application (especially
since our application is the only one exhibiting this behavior).  I'm
trying to find out what is causing this behavior to try to see how to
address it.

Here's a summary of some test code used to do the file export:

        response.setContentType("application/excel");
        response.setHeader("Content-Disposition", "multi-part
attachment;filename=\"" + defaultFileName + "\";");
        PrintStream os = new PrintStream(((ServletResponse)
response).getOutputStream());
        byte[] byte_1darray = {'1', '2', '3'};
        os.write(byte_1darray, 0, 3);
        
facesContext.getApplication().getStateManager().saveSerializedView(faces
Context);
        facesContext.responseComplete();

Note that I also tried setting the content type to text.html, but the
result was the same.

Has anyone else experienced this problem?  Can anyone explain what is
going on?

- Brendan

Reply via email to