Hi
I try pass data to report. First of all. I create template in iRaport ver 5.6.0 . In java code I cerate action like below
private Action getStoragePrintionAction() {
return new ItemTrackingAction(groupTable, "orderItemToDocuments").withCaption("Print`Preformatted text`")
.withHandler(event -> {
LoadContext<Report> lContext = new LoadContext<>(Report.class);
lContext.setQueryString("select r from report$Report r where r.id = '2a313f4b-9931-3b9d-f608-32f26e9274f4' ");
Report report = dataService.load(lContext);
Map<String, Object> reportParams = new HashMap<>();
reportParams.put("entity", getGroupTable().getSingleSelected());
ReportGuiManager reportGuiManager = AppBeans.get(ReportGuiManager.class);
reportGuiManager.printReport(report, reportParams);
});
}
In this case I try print order document. How can I pass entity Document, to report. In this example I get entity from groupTable
Map<String, Object> reportParams = new HashMap<>();
reportParams.put("entity", getGroupTable().getSingleSelected());
but this solution not working and report is empty. Maybe I have to mapping entity attributes to fields in iReport. Any suggestion ?
shchienko
(Nikita Schienko)
June 28, 2019, 8:10am
#3
Hello, @andrzej.paluch72
Please send a test project with your problem or archive of the report so that we can help you.
You can also see sample reports. The report documentation has a sample report for the JasperReport template.
https://doc.cuba-platform.com/reporting-7.0/example_jasper.html
You can download the test project “Library” and try out JasperReport there.
Regards,
Nikita
Hello Nikita
My main problem is how can I pass data to report in java code.
I invoke raport like below
ReportGuiManager reportGuiManager = AppBeans.get(ReportGuiManager.class);
reportGuiManager.printReport(report, reportParams);
In simple which I find data is pass by Groovy script
result.add(['literature_type_name': lt.name,
'books_instances_amount': count,
'reference_books_instances_amount': refCount])
I’d like pass the same data in java code.
I find then I may use groovy script.
I attach jrxml script. ReciptDocumentQuantityAndValue.zip (17.6 KB)
please change file extension on jrxml. I’d like set customer_company field e.g in groove script.
I try set const value on the beginning in this way
def result = []
result.add(['customer_company ': "xxxx"])
return result
but this solution not working and report is empty.
shchienko
(Nikita Schienko)
July 1, 2019, 8:49am
#7
Hello @andrzej.paluch72
I tried to reproduce your sample report. You did everything right, but you made a small mistake.
You have an extra space in the variable name “customer_company”.
Fix the code:
def result = []
result.add(['customer_company': "xxxx"])
return result
Regards,
Nikita