Hi Zied,

have you looked at the wiki?

http://wiki.apache.org/myfaces/Sending_Files

the important thing is:

FacesContext.getCurrentInstance().responseComplete();



Regards,
    Volker

2008/3/6, Zied Hamdi <[EMAIL PROTECTED]>:
> Hi,
>
> I wrote my code based on the example app.
>
>
>             public String downloadInvoicePDF() throws Throwable {
>
>                   HttpServletResponse response = (HttpServletResponse)
> getFacesContext().getExternalContext().getResponse();
>
>                   getParams( getCurrentCommandExecuter()
> ).setPdfOutputStream( response.getOutputStream() );
>
>                   response.setContentType( "application/pdf" );
>
>                   // always outside the page
>
>                   if( true ) {
>
>                         response.setHeader( "Content-Disposition",
> "attachment; filename=invoice.pdf" );
>
>                   }
>
>                   getCurrentCommandExecuter().execute(
> ContractRequests.WRITE_INVOICE_PDF );
>
>                   return null;
>
>             }
>
>
>
> In the execute() method I use the response output stream directly in my
> iText code. The problem is that there's a lot of tobago headers that are
> appended to the response (I joined the generated pdf for the complete
> content): this is my pdf binary content when I click save file:
> %PDF-1.4
> ...
> trailer
> <</Root 5 0 R/ID
> [<139a1a074706ebacb897006a1e3115be><0dfcff490c7f009f4523cb80723d5d9b>]/Info
> 6 0 R/Size 7>>
> startxref
> 669
> %%EOF
> <html xmlns="http://www.w3.org/1999/xhtml";
> xmlns:jsp="http://java.sun.com/JSP/Page";
>  ><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
> <html
> ><head
> ><script type="text/javascript"
> >
> <!--
> var TbgHeadStart = new Date();
> // -->
>  </script><title
> >Into Services: Le Logiciel pour les prÃ(c)stataires de service</title><link
> rel="stylesheet"
> href="/IntoServicesWeb/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/style/style.css"
> type="text/css"
>  ><link rel="stylesheet"
> href="/IntoServicesWeb/org/apache/myfaces/tobago/renderkit/html/scarborough/msie/style/style.css"
> type="text/css"
> ><link rel="stylesheet"
> href="/IntoServicesWeb/org/apache/myfaces/tobago/renderkit/html/speyside/standard/style/style.css"
> type="text/css"
>  ><link rel="stylesheet"
> href="/IntoServicesWeb/org/apache/myfaces/tobago/renderkit/html/speyside/msie/style/style.css"
> type="text/css"
> ><link rel="stylesheet"
> href="/IntoServicesWeb/org/apache/myfaces/tobago/renderkit/html/richmond/standard/style/style.css"
> type="text/css"
>  ><link rel="stylesheet"
> href="/IntoServicesWeb/org/apache/myfaces/tobago/renderkit/html/richmond/msie/style/style.css"
> type="text/css"
> ...
>
> it seams tobago intercepts the response and adds its header even if the fils
> is a pdf.
>
> Any hint please?
>
> Regards,
> Zied
>
>
>
> --
> Zied Hamdi
> www.into-i.fr
> (previously in 2003)
> zatreex.sf.net


-- 
inexso - information exchange solutions GmbH
Bismarckstraße 13      | 26122 Oldenburg
Tel.: +49 441 4082 356 |
FAX:  +49 441 4082 355 | www.inexso.de

Reply via email to