[JBoss Seam] - Re: how to download a file via Seam& JSF,
by tynor
Our application uses the same technique as discussed in this thread for downloading files (see below).
This works, but if any messages (FacesMessage) are queued during the generation of the downloaded content, they are not displayed to the user since the facesContext.responseComplete() interrups the JSF lifecycle and the view is never rerendered.
Is there a way to generate downloadable content, as below, but still refresh the browser view, showing any pending messages? In many cases, we wish to provide downloadable content, but also include warning messages (e.g., "Warning: generated report includes partially validated records").
Thanks!
| HttpServletResponse response = (HttpServletResponse)facesContext.getExternalContext().getResponse();
| try {
| response.setContentType(contentType);
| response.setHeader( "Content-Disposition", "attachment; filename=\""
| + name + "\";");
| response.getOutputStream().write(fileData);
| response.setStatus(HttpServletResponse.SC_OK);
| response.getOutputStream().close();
| facesContext.responseComplete();
| } catch (IOException ex) {
| log.error("Error writing file data (#0 bytes) to response", ex, fileData.length);
| }
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4124870#4124870
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4124870
18 years, 2 months