On 11/1/06, Gonzalo Nuñez <[EMAIL PROTECTED]> wrote:
I am trying to integrate JasperReports, I want to know which is the best
form to integrate it with myfaces and if there is a component like
exportExcel that uses JasperReports.

We are using JasperReports with MyFaces and Facelets.  We thought
about writing a component for the exporters but it was unnecessary.
Basically the managed beans call into business logic classes that
execute Jasper.  the managed beans store the JasperPrint object
internally and we provide other action methods to run the PDF
exporter, etc.  It looks something like this:

public class MyBean {
 public String runReport() {
   // execute Jasper.
   // execute HTML Exporter
   StringBuffer htmlOutput = ...;
 }

 public String exportPDF() {
    FacesContext context = ...;
    HttpServletResponse response = (HttpServletResponse)
        facesContext.getExternalContext().getResponse();
    response.setContentType( "application/pdf");
    // Call Jasper Exporter for PDF.
    outputStream.flush();
    outputStream.close();
    facesContext.responseComplete();
 }
}

That's it in a nutshell.

Greg

Reply via email to