Francois Lacoursiere
Francois Lacoursiere

Reputation: 131

Having trouble with BIRT 4.3 new POJO DataSource

I am following the example at http://www.eclipse.org/birt/phoenix/project/notable4.3.php#jump_3 and I can't seem to get it to work properly. At the step where you define the new DataSet (New Birt POJO Data Set), I can't seem to find the 'POJO Data Set Class Name'. The matching item widget remains empty. I tried editing the rptdesign with the source tab trying all kind of variations (with/without package name), nothing does it. Anybody had success with this new feature of BIRT ?

Upvotes: 1

Views: 3560

Answers (1)

Francois Lacoursiere
Francois Lacoursiere

Reputation: 131

Ok, my bad. It would have been easier if we had to implement an interface rather than trying to deduce how birt reads a custom pojo dataset.

So on the example at http://www.eclipse.org/birt/phoenix/project/notable4.3.php#jump_3 everything worked as described except for the class CustomerDataSet. Here is the implementation of the class CustomerDataSet that worked for me.

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

public class CustomerDataSet {

public Iterator<Customer> itr;

public List<Customer> getCustomers() {
    List<Customer> customers = new ArrayList<Customer>();

    Customer c = new Customer(103);
    c.setCity("City1");
    c.setCountry("Country1");
    c.setCreditLimit(100);
    c.setName("aName1");
    c.setState("state1");
    customers.add(c);

    c = new Customer(104);
    c.setCity("City2");
    c.setCountry("Country2");
    c.setCreditLimit(200);
    c.setName("aName2");
    c.setState("aStat2");
    customers.add(c);

    c = new Customer(105);
    c.setCity("City3");
    c.setCountry("Country3");
    c.setCreditLimit(300);
    c.setName("aName3");
    c.setState("aStat3");
    customers.add(c);

    return customers;
}

public void open(Object obj, Map<String,Object> map) {
}

public Object next() {
    if (itr == null)
        itr = getCustomers().iterator();
    if (itr.hasNext())
        return itr.next();
    return null;
}

public void close() {
}
}

Upvotes: 6

Related Questions