Reputation:
I have a POJO that compiles data from various sources into a single object. The object is instantiated with a single parameter. Example:
Invoice inv=new Invoice(1239);
This will bring back a complete invoice containing other POJOs populated with data from various sources (such as the billing and shipping addresses as Address
objects).
Can I use this as a data source within iReport?
Upvotes: 0
Views: 3656
Reputation: 4843
You could try use a JRMapCollectionDataSource
from which you can build a DataSource from a collection.
You could take the values from the POJO object and place them into a collection if possible.
Here is some sample code for constructing a DataSource.
Collection<Map<String, Object>> myColl = new ArrayList<Map<String,Object>>();
Map<String, Object> map1 = new HashMap<String, Object>();
map1.put("Field1","Value1");
map1.put("Field2","Value2");
map1.put("Field3", someObject);
myColl.add(map1);
JRMapCollectionDataSource source = new JRMapCollectionDataSource(myColl);
Another option would be to create a custom datasource by implementing JRRewindableDataSource
or JRDataSource
.
Upvotes: 2