utiliser JasperReports avec JSF
	
	
		Salut tout le monde. Je n'arrive pas à afficher un PDF dans le browser. Est-ce que quelqu'un a un exemple concret, svp?
J'ai essayé d'appliquer la technique suivante (reprise dans le tutoriel de JasperReports):
	Code:
	
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
   | 
public class ReportGenerator {
    public void generateReport(ActionEvent event)
	    throws ClassNotFoundException, SQLException, IOException,
	    JRException {
	
	Connection connection;
	FacesContext context = FacesContext.getCurrentInstance();
	HttpServletResponse response = (HttpServletResponse) context
		.getExternalContext().getResponse();
	InputStream reportStream = context.getExternalContext()
		.getResourceAsStream("/src/reports/mysqlReport.jasper");
	ServletOutputStream servletOutputStream = response.getOutputStream();
	Class.forName("com.mysql.jdbc.Driver");
	connection = DriverManager
		.getConnection("jdbc:mysql://localhost:3306/test?user=root&password=pwd");
	JasperRunManager.runReportToPdfStream(reportStream,
		servletOutputStream, new HashMap<String, String>(), connection);
	connection.close();
	response.setContentType("application/pdf");
	servletOutputStream.flush();
	servletOutputStream.close();
    }
}
Ma page jsp:
	Code: 
	
 1234567891011  |  
<f:view>
	<h:outputText value="Click on the link below to generate the
report." />
	<h:form>
		<h:commandLink action="generate_report"
			actionListener="#{reportGenerator.generateReport}">
			<h:outputText value="Generate Report" />
		</h:commandLink>
	</h:form>
</f:view> |  
  
  | 
 Mais là ils utilisent MyFaces et avec jsf de SUN_RI cea ne fonctionne pas:(
Ca donne l'erreur suivante:
	Code:
	
1 2 3 4 5 6 7 8
   |  
GRAVE: Received 'java.lang.NullPointerException' when invoking action listener '#{reportGenerator.generateReport}' for component 'j_id_jsp_320462548_3'
22-nov.-2007 12:35:42 javax.faces.event.MethodExpressionActionListener processAction
GRAVE: java.lang.NullPointerException
	at java.io.ObjectInputStream$PeekInputStream.read(ObjectInputStream.java:2264)
	at java.io.ObjectInputStream$PeekInputStream.readFully(ObjectInputStream.java:2277)
	at java.io.ObjectInputStream$BlockDataInputStream.readShort(ObjectInputStream.java:2748)
.... | 
 et à la fin ceci:
	Code:
	
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
   |  
22-nov.-2007 12:35:42 com.sun.faces.lifecycle.LifecycleImpl phase
ATTENTION: executePhase(RENDER_RESPONSE 6,com.sun.faces.context.FacesContextImpl@4e2f0a) threw exception
javax.faces.FacesException: org.apache.jasper.JasperException: An exception occurred processing JSP page /generate.jsp at line 12
 
9: <title>Report Generation</title>
10: </head>
11: <body>
12: <f:view>
13: 	<h:outputText value="Click on the link below to generate the
14: report." />
15: 	<h:form>
 
 
Stacktrace:
	at com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:413)
	at com.sun.faces.application.ViewHandlerImpl.executePageToBuildView(ViewHandlerImpl.java:442)
	at com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:115)
	at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:106)
	at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
...  | 
 Merci pour l'aide.