简体   繁体   中英

How can I use Java objects as data sets in Eclipse BIRT?

I basically followed this tutorial: http://www.vogella.com/tutorials/EclipseBIRT/article.html

Now I have two Java classes, Mock and MockContainer , that look like this:

package reports;

public class Mock {

    private int x;
    private double y;

    public Mock(int x, double y) {
        this.x = x;
        this.y = y;
    }

    public int getX() {
        return x;
    }

    public void setX(int x) {
        this.x = x;
    }

    public double getY() {
        return y;
    }

    public void setY(double y) {
        this.y = y;
    }

}

...

package reports;

import java.util.ArrayList;
import java.util.List;

public class MockContainer {

    public MockContainer() {

    }

    public List<Mock> getMockList() {
        List<Mock> mocks = new ArrayList<Mock>();

        mocks.add(new Mock(1000, +2.5));
        mocks.add(new Mock(2000, +1.5));
        mocks.add(new Mock(3000, +0.5));
        mocks.add(new Mock(3000, -0.5));
        mocks.add(new Mock(2000, -1.5));
        mocks.add(new Mock(1000, -2.5));

        return mocks;
    }

}

Also, I have a Scripted Data Source data_source and a Data Set data_set with two columns, x (Integer) and y (Decimal).

But I have problems writing the JavaScripts. My JavaScripts open and fetch in data_set look like this:

count = 0;

mockContainer = new Packages.reports.MockContainer();

mockList = mockContainer.getMockList();

...

if (count < mockList.size()) {
    row["x"] = mockList.get(count).getX();
    row["y"] = mockList.get(count).getY();

    count++;

    return true;
} else {
    return false;
}

But Preview Results stays empty...

我不知道为什么结果没有显示在预览中,但是最后却起作用了...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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