I'm rendering my BIRT reports through the provided Java engine. I use this library for that:
<dependency>
<groupId>org.eclipse.birt.runtime</groupId>
<artifactId>viewservlets</artifactId>
<version>4.5.0</version>
</dependency>
However, my report parameters are provided through a HTTP request, where I specify the template to be used and the report parameters too. So when I retrieve them from the URL I don't know their types anymore since they're converted to String, so I would like to know the types for the scalar-parameters in the given report template, in order to cast the parameters to their concrete type.
IReportRunnable runnable = engine.openReportDesign(design);
IRunAndRenderTask task = engine.createRunAndRenderTask(runnable);
task.run();
As I'm using this piece of code to render the report from the template, is there some way to retrieve the scalar parameter types either from IReportRunnable
or IRunAndRenderTask
? Since parameters are declared in the template file and being it a XML file, they would be parseable, but would be good to know if the engine API supports this.
Just found it, it looks like a bit tricky, though. We need to create a parameter definition task over the runnable element:
IReportRunnable runnable = engine.openReportDesign(design);
IGetParameterDefinitionTask paramTask = engine.createGetParameterDefinitionTask(runnable);
Then, we access the definition through the parameter name and we can get the type value for the parameter (i.e. "string"):
paramTask.getParameterDefn("my_parameter_name").getHandle().getElement()
.getProperty(null, "dataType").toString();