Empty table with javabean collection datasource ? (simple)

Jaspersoft Community 'Read-Only' as of July 8, 2022

Transition to New TIBCO Community Just Weeks Away

You can still search, review wiki content, and review discussions in read-only mode. Please email community@tibco.com with questions or issues requiring TIBCO review or response.

Hello community,

i can't get the content of a collection of beans into a table :(

here is my bean:

public class MyBean {
    public String header;
    public String row;
    public String value;
    public MyBean(final String header, final String row, final String value) {
        this.row = row;
        this.header = header;
        this.value = value;
    public String getHeader() {
        return header;
    public void setHeader(final String header) {
        this.header = header;
    public String getRow() {
        return row;
    public void setRow(final String row) {
        this.row = row;
    public String getValue() {
        return value;
    public void setValue(final String value) {
        this.value = value;
And, here is my Factory:
public class BeanFactory {
* @param args
public static void main(final String[] args) {
public static List<MyBean> createBeanCollection() {
// TODO Auto-generated method stub
ArrayList<MyBean> beans = new ArrayList<MyBean>();
        MyBean a1 = new MyBean("header1", "row1", "VALUE11");
        MyBean a2 = new MyBean("header2", "row1", "VALUE12");
        MyBean a3 = new MyBean("header3", "row1", "VALUE13");
        MyBean b1 = new MyBean("header1", "row2", "VALUE21");
        MyBean b2 = new MyBean("header2", "row2", "VALUE22");
        MyBean b3 = new MyBean("header3", "row2", "VALUE23");
        MyBean c1 = new MyBean("header1", "row3", "VALUE31");
        MyBean c2 = new MyBean("header2", "row3", "VALUE32");
        MyBean c3 = new MyBean("header3", "row3", "VALUE33");
        MyBean d1 = new MyBean("header1", "row4", "VALUE41");
        MyBean d2 = new MyBean("header2", "row4", "VALUE42");
        MyBean d3 = new MyBean("header3", "row4", "VALUE43");
        // JRBeanCollectionDataSource ds = new JRBeanCollectionDataSource(beans);
        System.out.println("Done Creating Beans");
        return beans;

So now you're in my universe, can someone explain why:

  • The data adapter receives an incorrect amount of beans (3x)
  • The table does not show data when the report is generated
  • The report is waaay too long

Thank you,

best regards


jeanroch.sales's picture
Joined: Feb 21 2014 - 6:27am
Last seen: 8 years 4 months ago

2 Answers:


The other problem which I can see is here is that ,the beans you have created should be at last should be storred in a collection/Array which should be fetched via report.

In the case of collection/ Array of beans, it could be looped in the Detail band and that will produce correct results. So Refer to the above links I have posted there are code snippets too . Go through them that will help you get the concept.


Hope that this helps.


Ankur Gupta

Ankur Gupta's picture
Joined: Jan 21 2013 - 10:36pm
Last seen: 4 months 2 weeks ago

Thank you for your help :)
I don't understand why I would need to create a custom Datasource when there is a JRBeanCollectionDatasource already implemented.
The table is located in the detail band...
Do I have to recode the Datasource anyway ?
How do I make the report fetch my collection ?

From what I read in your articles (very interesting by the way), it shouldn't take long nor be complicated, but still I puzzles me that there is no easier way.

As well, what package is JRDataSourceProvider in ?
Last note, I use JasperSoft Studio (not iReport, should I use iReport?).

Your help is highly appreciated.

jeanroch.sales - 8 years 4 months ago

I just succeeded in accessing my beans, by using the simple variable (drag & dropped in the details section, created a Label) but I can't get those in a table (as one per line).
Something must be missing in the table config.

jeanroch.sales - 8 years 4 months ago

Hi ,

I have a video made on the same subject have a look

You can also go through a artilcle for the same 

Do let me know if you need further help

Ankur Gupta

Ankur Gupta's picture
Joined: Jan 21 2013 - 10:36pm
Last seen: 4 months 2 weeks ago