1 Reply Latest reply on Jun 12, 2006 5:12 PM by Jin Wang

    jasper report in Seam: losing conversation

    Jin Wang Newbie

      I am not able to keep the old conversation once a jasper report PDF file is displayed. I have a download page that shows some information and a download button. The first download works fine. The page blows up the second time I click on the download button because the In variables are not available in the conversation context.

      Here is the code in the download button:

      byte[] pdf = createPdfReport();

      FacesContext faces = javax.faces.context.FacesContext.getCurrentInstance();
      HttpServletResponse response = (HttpServletResponse) faces.getExternalContext()
      .getResponse();

      response.setContentType( "application/pdf" );
      response.setContentLength( pdf.length );
      response.setHeader( "Content-disposition", "attachment; filename=\"" + createFileName() + "\"" );
      ServletOutputStream out;
      try
      {
      out = response.getOutputStream();
      out.write( pdf );
      }
      catch ( IOException ex )
      {
      log.error( "Could not output file:" + ex );
      }

      faces.responseComplete();

      return null;


      SeamPhaseListener does try to keep the conversation alive in afterPhase(). But the way it does it is writing conversationId to the response. The response in this case is the PDF file, which never comes back.

      Another odd thing is that it always tries to reload the download page no matter which link I click on the second time. And it goes from restore_view phase to render_response phase without going through other phases.

      Anybody had success with jasper reports in Seam application? Any suggestion is greatly appreciated.