Reputation: 2062
I created a BIRT 4.3.0 report using the following code. The main point is: I want to pass a parameter foo
to the dataSet:
public File actionPdf() throws EngineException {
IReportEngine engine = getEngine();
// Open the report design
IReportRunnable design = null;
design = engine.openReportDesign("c:\\hello_world.rptdesign");
IRunAndRenderTask task = engine.createRunAndRenderTask(design);
task.setParameterValue("foo", "bar");
task.validateParameters();
PDFRenderOption PDF_OPTIONS = new PDFRenderOption();
File f = new File("xyz.pdf");
PDF_OPTIONS.setOutputFileName(f.getAbsolutePath());
PDF_OPTIONS.setOutputFormat("pdf");
task.setRenderOption(PDF_OPTIONS);
task.run();
task.close();
return f;
}
and the dataSet looks as follows:
public class ActionsPerDateDataSet implements IPojoDataSet {
public void open(Object obj, Map<String,Object> map) {
System.out.println( obj + " map: " + map + " size: " + map.size())
}
2015-11-03T13:23:18.993+0100|Information {org.eclipse.datatools.connectivity.oda.util_consumerResourceIds=org.eclipse.datatools.connectivity.oda.util.ResourceIdentifiers@24a1f3df, org.eclipse.birt.data.engine.expression.compareHints=org.eclipse.birt.data.engine.expression.CompareHints@99fdef1, OdaConsumerId=org.eclipse.datatools.connectivity.oda.profile.connectionPropertyService, PDF_RENDER_CONTEXT=org.eclipse.birt.report.engine.api.PDFRenderContext@491c843} map: {} size: 0
But there is no parameter foo
set.How can I get it?
Upvotes: 2
Views: 1657
Reputation: 54
You'll need to define the parameter in the report Design.
Upvotes: 1
Reputation: 2669
From outside, you pass parameters to the report, not to the dataset. You have to distinguish between report parameters and dataset parameters. Inside the report, a dataset parameter can get its value from a report parameter, but this is not automatic. A dataset parameter could also get its value from the layout context (see the dataset parameter binding button in the properties).
See the BIRT documentation for details.
If you are coming from other report design tools, you may find this cumbersome and overly complicated, but in fact it is a great feature, because this allows reusing the same dataset several times within a report and is fundamental for reusing components by referencing them from libraries.
Upvotes: 2