Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Integrating BIRT Runtime with JSF
simteq
<p>I am using runtime 4.4.1 and Report Studio in Eclipse.</p>
<p>I have an existing web app written using JSF and am trying to integrate a report into it. I have a screen which allows the selection of a customer based on data held in an Oracle DB. I have created a report to display the customer details which takes a single parameter for the customer ID. The snippet of the JSF bean is:</p>
<p>String status = "GenerateCustomerFacilitiesReport";<br>
if ( selectedCustomer != null && !selectedCustomer.equals("NONE") ) {<br>
try {<br>
// start engine<br>
status = "starting engine";<br>
EngineConfig engineConfig = new EngineConfig();<br>
Platform.startup( engineConfig );<br>
IReportEngineFactory factory = (IReportEngineFactory) Platform.createFactoryObject( IReportEngineFactory.EXTENSION_REPORT_ENGINE_FACTORY );<br>
IReportEngine engine = factory.createReportEngine( engineConfig );<br>
<br>
// generate report<br>
status = "generating report";<br>
// Get context<br>
String context = FacesContext.getCurrentInstance().getExternalContext().getRealPath("/");<br>
String reportName = context + "reports/" + CUSTOMERFACILITIESREPORT;<br>
IReportRunnable reportDesign = engine.openReportDesign( reportName );<br>
IRunAndRenderTask task = engine.createRunAndRenderTask( reportDesign);<br>
IGetParameterDefinitionTask parameterDefinition = engine.createGetParameterDefinitionTask( reportDesign);<br>
parameterDefinition.evaluateDefaults();<br>
HashMap<String,String> params = (HashMap)parameterDefinition.getDefaultValues();<br>
params.put( CUSTOMERID, selectedCustomer);<br>
task.setParameterValues( params);<br>
// set render options including output type<br>
PDFRenderOption options = new PDFRenderOption();<br>
ByteArrayOutputStream outs = new ByteArrayOutputStream();<br>
options.setOutputStream(outs);<br>
options.setOutputFormat("html");<br>
task.setRenderOption(options);</p>
<p> </p>
<p><span style="color:#ff0000;">// Add code to generate the report into String customerFacilitiesReport which gets picked up by jsp.</span></p>
<p>
// stop engine<br>
status = "Stopping report engine";<br>
engine.destroy();<br>
Platform.shutdown();<br>
log.info("Report generated OK");<br>
}<br>
catch ( Exception e ) {<br>
log.error("Failure in generating the report:\nStatus: " + status + "\nReason: " + e.getMessage());<br>
addErrorMessage("ReportBean","Failed to generate report, see log for details");<br>
}<br>
<br>
}</p>
<p> </p>
<p>I am struggling with the last bit of how to actually generate the report and also, does the generation use the datasource defined in the rptdesign.</p>
Find more posts tagged with
Comments
JFreeman
<p>Take a look at the <a data-ipb='nomediaparse' href='
http://developer.actuate.com/community/forum/index.php?/files/file/1028-using-jsf-20-with-birt/'>Using
JSF 2.0 with BIRT devshare</a> and the <a data-ipb='nomediaparse' href='
http://blogs.actuate.com/using-jsf-2-0-with-birt/'>Using
JSF 2.0 with BIRT blog</a> that is associated with it.</p>
<p> </p>
<p>As for the data source, I do believe it should use the Data Source defined within the report design if it is not specified or overwritten in the Java code.</p>
mwilliams
And the BIRT with JSF Integration Guide (essentially the same as the stuff Jesse posted):<br><br><a data-ipb='nomediaparse' href='
http://developer.actuate.com/deployment-center/integrating-birt-into-applications/birt-with-jsf/'>http://developer.actuate.com/deployment-center/integrating-birt-into-applications/birt-with-jsf/</a>
;
Emad Omara
<p>could you please tell me the setup steps , </p>
<p>I need to know which jars exactly to include in my app ? </p>
<p>and I found many jars !! </p>