myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Thomas Gaudin" <tho...@gmail.com>
Subject Problem when report generation and JSF navigation
Date Tue, 04 Apr 2006 12:08:32 GMT
Hi,

I am using JasperReport to generate PDF files "on the fly".
It is working fine the first time I click on the link to the report but it
fails alternatively every 2 clicks exactly...
I guess I am somehow messing up the navigation mecanism but I don't know
where to start my investigation.
Any hint is warmly welcome.
Thanks,

Thomas

Here is the code :
--------------------
JSF Bean :
public class Reports extends BasePage implements Serializable {
    public String users() {
        List results = userManager.getUsers(null);
        Map parameters = new HashMap();
        parameters.put("format", "pdf");
        parameters.put("WEBDIR", getServletContext().getRealPath("/"));
        try{
            InputStream is =
getServletContext().getResourceAsStream("/WEB-INF/reports/userList.jrxml");
            JRBeanCollectionDataSource ds = new
JRBeanCollectionDataSource(results);

            getResponse().setContentType("application/pdf");
            getResponse().addHeader("Content-Disposition", "attachment;
filename=userList.pdf");

            JasperDesign jasperDesign = JRXmlLoader.load(is);
            JasperReport jasperReport = JasperCompileManager.compileReport
(jasperDesign);
            JasperPrint jasperPrint =
JasperFillManager.fillReport(jasperReport,
parameters, ds);
            JasperExportManager.exportReportToPdfStream(jasperPrint,
getResponse().getOutputStream());

            getFacesContext().responseComplete();
        }
        catch(Exception e){
            log.error(e);
        }
        return null;
    }
--------------------
The link to generate report :
<h:commandLink value="report" action="#{reports.users}"/>
--------------------
faces-config.xml :
     <managed-bean>
        <managed-bean-name>reports</managed-bean-name>
        <managed-bean-class>org.appfuse.webapp.action.Reports
</managed-bean-class>
        <managed-bean-scope>request</managed-bean-scope>
        <managed-property>
            <property-name>userManager</property-name>
            <value>#{userManager}</value>
        </managed-property>
    </managed-bean>
--------------------

Mime
View raw message