I have this object structure, to use like Java Bean in mi jasper report,
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
When I create a list into jasper report I define the "job list" JRDataSource expression
this way:
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
?
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
Then when I set the datasource for responsibilities list did this:
References: https://community.jaspersoft.com/questions/508346/getting-current-object