diff --git a/src/main/java/info/bukova/isspst/reporting/PredefinedGenerator.java b/src/main/java/info/bukova/isspst/reporting/PredefinedGenerator.java index 81a1f5f6..ec620509 100644 --- a/src/main/java/info/bukova/isspst/reporting/PredefinedGenerator.java +++ b/src/main/java/info/bukova/isspst/reporting/PredefinedGenerator.java @@ -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); + } + } } diff --git a/src/main/java/info/bukova/isspst/reporting/ReportDefinition.java b/src/main/java/info/bukova/isspst/reporting/ReportDefinition.java index 1c813996..b5a1b413 100644 --- a/src/main/java/info/bukova/isspst/reporting/ReportDefinition.java +++ b/src/main/java/info/bukova/isspst/reporting/ReportDefinition.java @@ -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 params; private List fieldsToPrint; private String reportTitle; + private Service service; public ReportDefinition() { params = new HashMap(); @@ -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 getService() { + return service; + } + + public void setService(Service service) { + this.service = service; + } + } diff --git a/src/main/java/info/bukova/isspst/ui/ListViewModel.java b/src/main/java/info/bukova/isspst/ui/ListViewModel.java index 4a1093e8..6884df8c 100644 --- a/src/main/java/info/bukova/isspst/ui/ListViewModel.java +++ b/src/main/java/info/bukova/isspst/ui/ListViewModel.java @@ -325,6 +325,7 @@ public class ListViewModel { 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(); } diff --git a/src/main/java/info/bukova/isspst/ui/reporting/ReportDialogVM.java b/src/main/java/info/bukova/isspst/ui/reporting/ReportDialogVM.java index 98873a23..fd56e04b 100644 --- a/src/main/java/info/bukova/isspst/ui/reporting/ReportDialogVM.java +++ b/src/main/java/info/bukova/isspst/ui/reporting/ReportDialogVM.java @@ -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 reports, @ExecutionArgParam("data") List data, - @ExecutionArgParam("singleObject") Object singleObject) { + @ExecutionArgParam("singleObject") Object singleObject, + @ExecutionArgParam("service") Service 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 getReports() {