Thanks. In your example, does one have to first write out the data to a file on the server? I see you set the header with attachment;filename=..., but then I also see that you have responseStream.write(selectedContent.getContentDate().getData()).
- Brendan -----Original Message----- From: Mike Kienenberger [mailto:[EMAIL PROTECTED] Sent: Friday, October 21, 2005 2:41 PM To: MyFaces Discussion Subject: Re: FileDownload capability? Here's one way. Note that facesContext.getResponseStream() is only valid during the render-response phase, so you'll have to access the HttpRequest directly (not sure how it works for portlets). public String downloadContentData() { Content selectedContent = (Content)this.announcementContentDataList.getRowData(); FacesContext facesContext = FacesContext.getCurrentInstance(); // OutputStream responseStream = facesContext.getResponseStream(); try { OutputStream responseStream = ((HttpServletResponse)facesContext.getExternalContext().getResponse()).g etOutputStream(); if (null == responseStream) throw new AbortProcessingException("responseStream is null"); HttpServletResponse response = (HttpServletResponse)facesContext.getExternalContext().getResponse(); response.setContentType(selectedContent.getContentType()); response.setHeader("Content-Disposition","attachment;filename=\"" + selectedContent.getContentId() + "\""); response.setContentLength(selectedContent.getContentData().getData().len gth); responseStream.write(selectedContent.getContentData().getData()); response.flushBuffer(); } catch (IOException exception) { // TODO Auto-generated catch block exception.printStackTrace(); } facesContext.responseComplete(); return null; } On 10/21/05, CONNER, BRENDAN (SBCSI) <[EMAIL PROTECTED]> wrote: > We have an application requirement saying that the user needs the > ability to push a button on our report page to download the report data > into a local file on the user's machine suitable for loading into a > spreadsheet. How can something like this be done? > > - Brendan >

