incubator-adffaces-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "William Hoover" <>
Subject RE: Providing Files / Streams as download-link with trinidad?
Date Tue, 27 Mar 2007 11:55:19 GMT

I have been struggling with the same problem when streaming files for download. I have tried
the solution described below, but I still recieve an java.lang.IllegalStateException- even
when calling FacesContext.getCurrentInstance().responseComplete(). This also breaks all of
the links/buttons on the page.

-----Original Message-----
From: []On Behalf Of
Matthias Wessendorf
Sent: Tuesday, March 27, 2007 4:48 AM
Subject: Re: Providing Files / Streams as download-link with trinidad?

Hello Jochen,

I've worked with Apache FOP for creating pdfs. iText or
JasperReports are also lib that help you on that task.

inside of your backing bean method (referenced by a commandLink or
cmdButton) you can do somthing like this:

public String pdf() {

  FacesContext ctx = FacesContext.getCurrentInstance();

  if(!ctx.getResponseComplete()) {

      HttpServletResponse response = (HttpServletResponse)

      byte[] file = //do some FOP, or ... stuff;

      response.setHeader("Content-Disposition", "inline;

      OutputStream out = response.getOutputStream();
      out.write(file, 0, file.length);


  return null;

This will work in p(l)ain servlet or struts world too (expect of the
usage of jsf api (like FacesContext))

However, the *magic* here is the responseComplete()
Signal the JavaServer Faces implementation that the HTTP response for
this request has already been generated (such as an HTTP redirect),
and that the request processing lifecycle should be terminated as soon
as the current phase is completed.

and yes... it's getResponseComplete() instead of isResponseComplete()


On 3/27/07, Jochen Traunecker <> wrote:
> Hello everybody,
> I'm just wondering if there is some Trinidad-specific / Faces-specific way to serve binary
downloads, like PDFs stored in a database. Or do I have to provide some link to a non managed
> Thanks,
> Jochen
> ___________________________________________________________
> Telefonate ohne weitere Kosten vom PC zum PC:

Matthias Wessendorf

further stuff:
mail: mwessendorf-at-gmail-dot-com

View raw message