I am generating a report from a JRBeanCollectionDataSource. This report is about a customer’s order.
This is my code
public class Customer
{
private String customerName;
private String customerNo;
private String customerAddress;
private ArrayList<CustomerOrder> customerOrders;
//Getters and Setters
}
private class CustomerOrder
{
private String itemName;
private BigDecimal amount;
private int itemQuantity;
//Getters and Setters
}
When a customer a report containing the customer details and a list of the customer orders need to be generated.
Since JRBeanCollectionDataSource takes a collection, this is what i did.
Customer cust; //Customer Instance
ArrayList<Customer> custList = new ArrayList<Customer>();
custList.add(cust);
JRBeanCollectionDataSource rptData = new JRBeanCollectionDataSource(custList);
How can i extract the CustomerOrder list in Customer and pass it as a subreport?
You should be able to set the datasource expression for the subreport:
The resulting xml should have a subreport tag that resembles:
The only other thing you need to check is that the
Languagefor the report properties is set toJava.