简体   繁体   English

List 到其他 List jasper 报告

[英]List into other List jasper report

I have this object structure, to use like Java Bean in mi jasper report,我有这个对象结构,在 mi jasper 报告中像 Java Bean 一样使用,

public class Person{
   private String name;
   private String lastname;
   private List<Job> jobs;
}

public class Job{
   private String jobName;
   private String companyName;
   private List<Reponsability> responsabilities;
}

All class with corresponding setters and getters所有具有相应settersgetters

When I create a list into jasper report I define the "job list" JRDataSource expression this way:当我在 jasper 报告中创建一个列表时,我以这种方式定义了“作业列表” JRDataSource expression

new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($F{jobs})

Now I want to create another list, "responsibilities list" on the "job list" , the question is:现在我想在“工作列表”上创建另一个列表, “职责列表” ,问题是:

How can I define the data source to get the corresponding job to pass into the JRDataSource Expression ?如何定义数据源以获取相应的作业以传递到JRDataSource Expression

I imagine something like this:我想象这样的事情:

new JRBeanCollectionDataSource(${jobs}.get($index).getResponsabilities())

but I can't get it work this但我不能让它工作

I found the solution to do this:我找到了解决方案来做到这一点:

Into the list, I created a variable called jobInstance进入列表,我创建了一个名为jobInstance的变量

    <field name="jobInstance" class="com.mypackage.example.Job">
        <fieldDescription><![CDATA[_THIS]]></fieldDescription>
    </field>

Then when I set the datasource for responsibilities list did this:然后当我为职责列表设置数据源时:

new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($F{jobInstance}.getResponsabilities())

References: https://community.jaspersoft.com/questions/508346/getting-current-object参考资料: https : //community.jaspersoft.com/questions/508346/getting-current-object

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM