Issue creating dynamic Report

WeirdAl
edited February 11, 2022 in Analytics #1
Hi,<br />
I am trying to create a dynamic BIRT Report by using the BIRT Report API.<br />
<br />
Therefore I created a simple reportdesign with a simple ScriptedDataSource. Finally I linked a ScriptedDataSetEventAdapter Java-Class to the report.<br />
<br />
<a class='bbc_url' href='http://imageshack.us'><img src='http://img131.imageshack.us/img131/3623/reportviewhh3.png' alt='Posted Image' class='bbc_img' /></a><br />
<br />
<br />
Then I managed to load the report via the reporting API.<br />
The dynamic created PDF file should now contain the table with the scripted DataSource (filled by the linked ScriptedDataSetEventAdapter). But it looks like no data could be found.<br />
<br />
<a class='bbc_url' href='http://imageshack.us'><img src='http://img235.imageshack.us/img235/9558/scripteddataseteventadawr2.png' alt='Posted Image' class='bbc_img' /></a><br />
<br />
I have got a few questions to this issue:<br />
<br />
1) When the classfile of the ScriptedDataSetEventAdapter could not be found, would I get an exception or would be the missing class file be ignored and the linked data is "only" empty?<br />
<br />
2) Have anyone an idea why the data could not be found?<br />
<br />
3) Are there any good examples available, where I could see how Java Event Handlers could be linked to a reportdesign?<br />
<br />
<br />
Finally, my class who process the BIRT loading (perhaps I have made a misstake here):<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
public class ProcessBIRTReporting {
public static final String PDF = RenderOption.OUTPUT_FORMAT_PDF;
// default engine home
private static final String ENGINE_HOME = "/WEB-INF/ReportEngine";

private final ByteArrayOutputStream outStream = new ByteArrayOutputStream();
private final EngineConfig config = new EngineConfig();

/**
*... cisAdapter = custom adapter which contains httpSession
*/
public ProcessBIRTReporting(Adapter cisAdapter, String outputFormat, BIRTStreamReadable designStream) throws EngineException {
this.configReport(cisAdapter);
this.prepareReport(outputFormat, designStream);
}

/**
* ...
*/
private void configReport(Adapter cisAdapter) {
final HttpSession httpSession = cisAdapter.findHttpServletRequest().getSession();
final ServletContext servletContext=httpSession.getServletContext();
config.setEngineHome(servletContext.getRealPath(ENGINE_HOME));
}

/**
* ...
*/
private void prepareReport(String outputFormat, BIRTStreamReadable designStream) throws EngineException{
final IReportEngine engine = new ReportEngine(config);
final IReportRunnable design = engine.openReportDesign(designStream.getInputStream());
final RenderOption renderOptions = new RenderOption();

renderOptions.setOutputFormat(outputFormat);
renderOptions.setOutputStream(outStream);

this.runTask(design, renderOptions, engine);
}

/**
* ...
*/
private void runTask(IReportRunnable design, RenderOption renderOptions, IReportEngine engine) throws EngineException {
final IRunAndRenderTask task = engine.createRunAndRenderTask(design);
HashMap test = task.getParameterValues();
task.setRenderOption(renderOptions);
task.run();
}

public byte[] getReportAsByteArray(){
return outStream.toByteArray();
}
}
</pre>
<br />
Thanks in advance<br />
Alex