从 BIRT 引擎获取报告模板参数类型 API
Getting report template parameter types from BIRT Engine API
我正在通过提供的 Java 引擎呈现我的 BIRT 报告。我为此使用了这个库:
<dependency>
<groupId>org.eclipse.birt.runtime</groupId>
<artifactId>viewservlets</artifactId>
<version>4.5.0</version>
</dependency>
但是,我的报告参数是通过 HTTP 请求提供的,我在其中指定要使用的模板和报告参数。因此,当我从 URL 中检索它们时,我不再知道它们的类型,因为它们已转换为 String,所以我想知道 [=] 的类型21=]标量参数 在给定的报告模板中,以便将参数转换为其具体类型。
IReportRunnable runnable = engine.openReportDesign(design);
IRunAndRenderTask task = engine.createRunAndRenderTask(runnable);
task.run();
当我使用这段代码从模板呈现报告时,是否有某种方法可以从 IReportRunnable
或 IRunAndRenderTask
中检索标量参数类型?由于参数是在模板文件中声明的,并且它是一个 XML 文件,因此它们是可解析的,但最好知道引擎 API 是否支持这个。
刚刚找到,不过看起来有点棘手。我们需要在可运行元素上创建一个参数定义任务:
IReportRunnable runnable = engine.openReportDesign(design);
IGetParameterDefinitionTask paramTask = engine.createGetParameterDefinitionTask(runnable);
然后,我们通过参数名访问定义,我们可以得到参数的类型值(即"string"):
paramTask.getParameterDefn("my_parameter_name").getHandle().getElement()
.getProperty(null, "dataType").toString();
我正在通过提供的 Java 引擎呈现我的 BIRT 报告。我为此使用了这个库:
<dependency>
<groupId>org.eclipse.birt.runtime</groupId>
<artifactId>viewservlets</artifactId>
<version>4.5.0</version>
</dependency>
但是,我的报告参数是通过 HTTP 请求提供的,我在其中指定要使用的模板和报告参数。因此,当我从 URL 中检索它们时,我不再知道它们的类型,因为它们已转换为 String,所以我想知道 [=] 的类型21=]标量参数 在给定的报告模板中,以便将参数转换为其具体类型。
IReportRunnable runnable = engine.openReportDesign(design);
IRunAndRenderTask task = engine.createRunAndRenderTask(runnable);
task.run();
当我使用这段代码从模板呈现报告时,是否有某种方法可以从 IReportRunnable
或 IRunAndRenderTask
中检索标量参数类型?由于参数是在模板文件中声明的,并且它是一个 XML 文件,因此它们是可解析的,但最好知道引擎 API 是否支持这个。
刚刚找到,不过看起来有点棘手。我们需要在可运行元素上创建一个参数定义任务:
IReportRunnable runnable = engine.openReportDesign(design);
IGetParameterDefinitionTask paramTask = engine.createGetParameterDefinitionTask(runnable);
然后,我们通过参数名访问定义,我们可以得到参数的类型值(即"string"):
paramTask.getParameterDefn("my_parameter_name").getHandle().getElement()
.getProperty(null, "dataType").toString();