Opraveno generování sestav, ve kterých je nutné lazy loadovat data.
This commit is contained in:
@@ -29,6 +29,7 @@ public class PredefinedGenerator implements Generator {
|
||||
try {
|
||||
JasperReport report = (JasperReport) JRLoader.loadObject(getReportFile());
|
||||
JRProperties.setProperty("net.sf.jasperreports.default.pdf.encoding", "Cp1250");
|
||||
loadLazyData();
|
||||
bytes = JasperRunManager.runReportToPdf(report, definition.getParams(), new JRBeanCollectionDataSource(definition.getDataSet()));;
|
||||
} catch (JRException e) {
|
||||
throw new ReportException(e);
|
||||
@@ -40,5 +41,15 @@ public class PredefinedGenerator implements Generator {
|
||||
protected File getReportFile() {
|
||||
return new File(ctx.getRealPath("WEB-INF/reports") + "/" + definition.getReport().getJasperFile() + ".jasper");
|
||||
}
|
||||
|
||||
private void loadLazyData() {
|
||||
if (definition.getService() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (Object o : definition.getDataSet()) {
|
||||
definition.getService().loadLazyData(o);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package info.bukova.isspst.reporting;
|
||||
|
||||
import info.bukova.isspst.services.Service;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
@@ -17,6 +19,7 @@ public class ReportDefinition implements Serializable {
|
||||
private Map<String, Object> params;
|
||||
private List<String> fieldsToPrint;
|
||||
private String reportTitle;
|
||||
private Service<Object> service;
|
||||
|
||||
public ReportDefinition() {
|
||||
params = new HashMap<String, Object>();
|
||||
@@ -87,6 +90,7 @@ public class ReportDefinition implements Serializable {
|
||||
fieldsToPrint.clear();
|
||||
dataSet = null;
|
||||
reportTitle = "";
|
||||
service = null;
|
||||
params.clear();
|
||||
}
|
||||
|
||||
@@ -98,4 +102,12 @@ public class ReportDefinition implements Serializable {
|
||||
this.reportTitle = reportTitle;
|
||||
}
|
||||
|
||||
public Service<Object> getService() {
|
||||
return service;
|
||||
}
|
||||
|
||||
public void setService(Service<Object> service) {
|
||||
this.service = service;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -325,6 +325,7 @@ public class ListViewModel<T extends DataModel> {
|
||||
params.put("reports", service.getReports());
|
||||
params.put("data", dataList);
|
||||
params.put("singleObject", dataBean);
|
||||
params.put("service", service);
|
||||
Window win = (Window) Executions.createComponents("/app/reporting/reportDialog.zul", null, params);
|
||||
win.doModal();
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package info.bukova.isspst.ui.reporting;
|
||||
import info.bukova.isspst.reporting.Report;
|
||||
import info.bukova.isspst.reporting.ReportDefinition;
|
||||
import info.bukova.isspst.reporting.ReportType;
|
||||
import info.bukova.isspst.services.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -27,7 +28,8 @@ public class ReportDialogVM {
|
||||
@Init
|
||||
public void init(@ExecutionArgParam("reports") List<Report> reports,
|
||||
@ExecutionArgParam("data") List<Object> data,
|
||||
@ExecutionArgParam("singleObject") Object singleObject) {
|
||||
@ExecutionArgParam("singleObject") Object singleObject,
|
||||
@ExecutionArgParam("service") Service<Object> service) {
|
||||
this.reports = reports;
|
||||
|
||||
if (data != null && data.size() > 0 && data.get(0).getClass() != reportDefinition.gatDataClass()) {
|
||||
@@ -36,6 +38,7 @@ public class ReportDialogVM {
|
||||
|
||||
dataList = data;
|
||||
this.singleObject = singleObject;
|
||||
reportDefinition.setService(service);
|
||||
}
|
||||
|
||||
public List<Report> getReports() {
|
||||
|
||||
Reference in New Issue
Block a user