myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From S├ębastien Marin <the.ma...@free.fr>
Subject Re: Problem when report generation and JSF navigation
Date Tue, 04 Apr 2006 12:38:33 GMT
Hello, i have the same problem. The first action is Ok but the second just do a
refresh or made error. It is the same process when we click on the back icon of
the web browser.

I would like to understand. Thanks
Selon Thomas Gaudin <thogau@gmail.com>:

-> 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