Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can pass multiple bean collections to a report by creating another bean that holds a beanCollection. Such a bean would look like this:</p> <pre><code>public class DataBean { private Collection beanCollection = null; public DataBean() { } public Collection getBeanCollection() { return beanCollection; } public void setBeanCollection(Collection beanCollection) { this.beanCollection = beanCollection; } } </code></pre> <p>I assume that the other collection will be of a different type than <code>ThemeBean</code>. I'm using <code>FruitBean</code> as an example. For each bean collection you want to pass, you create a <code>DataBean</code> and add it to a collection, then pass <em>that</em> collection to the report. So your code would change to be something like this:</p> <pre><code>List&lt;DataBean&gt; allData = new ArrayList&lt;DataBean&gt;(); //...Create and populate `List&lt;ThemeBean&gt; themes` DataBean db = new DataBean(); db.setBeanCollection(themes); allData.add(db); //...Create and populate `List&lt;FruitBean&gt; fruits` db = new DataBean(); db.setBeanCollection(fruits); allData.add(db); //... Load the report JRBeanCollectionDataSource ds = new JRBeanCollectionDataSource(allData); //... Fill the report </code></pre> <p>The report that you fill with this datasource will be a shell report, containing a subreport for each <code>DataBean</code> you created. There will only be one field available in this report: <code>$F{beanCollection}</code></p> <p>Set the datasource expression of the subreport(s) to </p> <p><code>new JRBeanCollectionDataSource($F{beanCollection})</code>. </p> <p>The fields for <code>ThemeBean</code> or <code>FruitBean</code> will then be available within the subreport.</p> <p>If you prefer to use list components instead of subreports, that would also work.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload