This content has been marked as final.
Show 3 replies
-
1. Re: File(data) Download problem...
jazir1979 Mar 2, 2007 12:02 AM (in response to waheed.murad)Hi,
I'm doing something similar to you for exporting jasper reports (JasperPrint) objects to various output formats.
I think perhaps you are missing the call to FacesContext.responseComplete(), but I will show you all of my code, because there are also various flush() and close() calls in there which I found were necessary...final HttpServletResponse response = (HttpServletResponse) context.getExternalContext().getResponse(); final OutputStream responseStream = response.getOutputStream(); response.setContentLength(stream.size()); response.setContentType(contentTypes.get(outputType)); if (outputType != ReportOutputType.HTML) { response.setHeader("Content-Disposition", "attachment; filename=report." + outputType); } responseStream.write(stream.toByteArray()); responseStream.flush(); responseStream.close(); response.flushBuffer(); context.responseComplete();
-
2. Re: File(data) Download problem...
newlukai Mar 5, 2007 10:58 AM (in response to waheed.murad)Hi jazir,
I tried your code in my application where I get a file out of a database blob and want to send it to the browser.
But I ran into a NullPointerException, since I don't get a HttpServletResponse object from the FacesContext object. Could it be that I inject the wrong context?@In private FacesContext context;
Or is it because I use ICEfaces, that I can't get a HttpServletResponse? Has somebody implemented a file download with ICEfaces?
Thanks in advance
Newlukai -
3. Re: File(data) Download problem...
newlukai Mar 7, 2007 10:03 AM (in response to waheed.murad)I got it. Almost. I'm stuck on a Seam/ICEfaces integration problem with embedded JavaScript.