http://wiki.apache.org/myfaces/Sending_Files
response.setContentType("application/pdf");
//This is another important attribute for the header of the response
//Here fileName, is a String with the name that you will suggest as a
name to save as
//I use the same name as it is stored in the file system of the server.
response.setHeader("Content-Disposition", "attachment;filename=\"" +
fileName + "\"");
On 4/19/07, wjones14 <[EMAIL PROTECTED]> wrote:
I just wanted to reply that I found an easy solution that works well, and the
customer is happy with it. Instead of opening the PDF report inline in a
new browser window, I am now setting the response header disposition type to
be "attachment" instead of "inline". So when the report is streamed back,
the user gets a standard Windows prompt to Open, Save, or Cancel the PDF
file. If there are validation errors, the backing bean simply posts a
FacesMessage with the error, and returns null to redisplay the parameter
page.
The code change was like this:
FacesContext context = FacesContext.getCurrentInstance();
HttpServletResponse response = (HttpServletResponse) context
.getExternalContext().getResponse();
response.setHeader("Content-Type", "application/pdf");
response.setHeader("Content-Disposition", "attachment; filename=" +
fileName);
--
View this message in context:
http://www.nabble.com/validation-with-commandLink-and-target-%3D-_blank-tf3601961.html#a10083530
Sent from the MyFaces - Users mailing list archive at Nabble.com.