I am using DynamicReports 4.1.1. since I depend on Java 1.6. The problem is, that all my reports are empty no matter which export format is being used. The pdfs have about 1600 Bytes, so there is no problem with writing as such. But no content. I have read that this can happen if the datasource ist empty, but this is not the case here. Has someone an idea?
private void build() {
try {
JRDataSource c = new JRBeanCollectionDataSource(createDataSource());
report()
.setTemplate(Templates.reportTemplate)
.columns(
col.column("Item", "item", type.stringType()),
col.column("Quantity", "quantity", type.integerType()),
col.column("Unit price", "unitPrice", type.bigDecimalType()))
.title(Templates.createTitleComponent("CollectionDatasource"))
.detailFooter(cmp.line())
.pageFooter(Templates.footerComponent)
.noData(Templates.createTitleComponent("NoData"), cmp.text("There is no data"))
.setDataSource(c);
report().toPdf(new FileOutputStream("report4.pdf"));
} catch (DRException e) {
e.printStackTrace();
}
}
private List<Data> createDataSource() {
List<Data> data = new ArrayList<Data>();
data.add(new Data("DVD", 5, new BigDecimal(30)));
data.add(new Data("Book", 8, new BigDecimal(11)));
data.add(new Data("PDA", 2, new BigDecimal(15)));
return data;
}
private class Data {
private String item;
private Integer quantity;
private BigDecimal unitPrice;
public Data(String item, Integer quantity, BigDecimal unitPrice) {
this.item = item;
this.quantity = quantity;
this.unitPrice = unitPrice;
}
public String getItem() {
return item;
}
public void setItem(String item) {
this.item = item;
}
public Integer getQuantity() {
return quantity;
}
public void setQuantity(Integer quantity) {
this.quantity = quantity;
}
public BigDecimal getUnitPrice() {
return unitPrice;
}
public void setUnitPrice(BigDecimal unitPrice) {
this.unitPrice = unitPrice;
}
@Override
public String toString() {
return "Data{" + "item=" + item + ", quantity=" + quantity + ", unitPrice=" + unitPrice + '}';
}
}