Discussions
Categories
Choose a Product
THRUST SERVICES
CORE APPS
CE PRODUCTS
...
Quick Links
POPULAR
HELPFUL TIPS
Groups
My Links
FOR SIGNED IN MEMBERS:
Back to website
Home
Developing Analytics Applications
Integrating BIRT Runtime with JSF
Migrateduser
<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
There are no comments yet