【问题标题】:Having trouble with BIRT 4.3 new POJO DataSourceBIRT 4.3 新 POJO 数据源出现问题
【发布时间】:2013-09-06 22:25:52
【问题描述】:

我正在关注http://www.eclipse.org/birt/phoenix/project/notable4.3.php#jump_3 的示例 我似乎无法让它正常工作。在定义新数据集(New Birt POJO 数据集)的步骤中,我似乎找不到“POJO 数据集类名称”。匹配的项目小部件保持为空。我尝试使用源选项卡编辑 rptdesign,尝试各种变体(带/不带包名称),但没有任何效果。有人在 BIRT 的这个新功能上取得了成功吗?

【问题讨论】:

    标签: java birt


    【解决方案1】:

    好吧,我的错。如果我们必须实现一个接口而不是试图推断 birt 如何读取自定义 pojo 数据集,那会更容易。

    所以在http://www.eclipse.org/birt/phoenix/project/notable4.3.php#jump_3 的示例中,除了CustomerDataSet 类之外,一切都按照描述的方式工作。这是对我有用的 CustomerDataSet 类的实现。

    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() {
    }
    }
    

    【讨论】:

    • 感谢您发布解决方案。我认为迭代器应该是私有的,并且在“open”方法而不是在 next() 中初始化。
    • @ Francois Lacoursiere 在我的情况下,我在数据源中看不到数据源类名。请帮助我。
    • 我一直在尝试推断,我已经推断出来了。您需要使用 public Object next() 方法的对象。它通过这个转换器eclipse.googlesource.com/birt/org.eclipse.birt/+/…
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-05-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多