Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/359.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Birt参数_Java_Birt - Fatal编程技术网

Java Birt参数

Java Birt参数,java,birt,Java,Birt,我使用以下代码创建了一个BIRT 4.3.0报告。要点是:我想向数据集传递一个参数foo: public File actionPdf() throws EngineException { IReportEngine engine = getEngine(); // Open the report design IReportRunnable design = null; design = engine.openReportDesign("c:\\hello_w

我使用以下代码创建了一个BIRT 4.3.0报告。要点是:我想向数据集传递一个参数
foo

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;
}
数据集如下所示:

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
公共类ActionsPerDateDataSet实现IPojoDataSet{
打开公共空(对象对象、地图){
System.out.println(obj+“map:+map+”大小:“+map.size())
}
2015-11-03T13:23:18.993+0100 |信息{org.eclipse.datatools.connectivity.oda.util_consumerResourceId=org.eclipse.datatools.connectivity.oda.util。ResourceIdentifiers@24a1f3df,org.eclipse.birt.data.engine.expression.compareHints=org.eclipse.birt.data.engine.expression。CompareHints@99fdef1,odacumerid=org.eclipse.datatools.connectivity.oda.profile.connectionPropertyService,PDF\u-RENderu CONTEXT=org.eclipse.birt.report.engine.api。PDFRenderContext@491c843}映射:{}大小:0

但是没有设置参数
foo
如何获取它?

从外部,您将参数传递到报表,而不是数据集。 您必须区分报表参数和数据集参数。 在报表内部,数据集参数可以从报表参数获取其值,但这不是自动的。数据集参数也可以从布局上下文获取其值(请参见属性中的“数据集参数绑定”按钮)

有关详细信息,请参阅BIRT文档


如果您来自其他报表设计工具,您可能会发现这一点既麻烦又过于复杂,但事实上这是一个很好的功能,因为它允许在报表中多次重用同一数据集,并且是通过从库中引用组件来重用组件的基础。

您需要在报表中定义参数设计


您在报告中定义了该参数了吗?我现在没有主动使用birt,所以我从心里回答。我记得,数据集没有参数。报告可以有参数,您可以在数据集中使用。嗯……我的计划是使用open方法中的参数从数据库加载数据。这通常是正确的方法吗方法?我记得我做过很多关于参数的工作。更改数据源、创建查询等。查看报表的生命周期,有几个地方可以放置ECMA脚本在生成报表时对报表进行操作。因此,理论上你的想法是正确的,因为我理解它是正确的。