How to pass List component values from subdataset to main dataset

1

Hi,

I'm creating an report with Jasper iReport Designer (5.6.0). I have a Page Header, Detail1 and Column Footer Band.

In the Detail1 band I placed a List component and within the List component 4 textfileds. Three textfields ( $F{currency_1}, $F{currency_2}, $F{currency_3} ) will show currency values. Now I would like to place three textfileds in the Column Footer band to show the SUM value of each column.

What I did:

I created a "dataset1" and there four fields. These four fields are placed within the List component. Then configured in the "Edit list datasource" the Dataset Run settings of the List component. The connection / datasource expression is "Use datasource expression" with "new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource(...)". On Java side I created an JUnit Test to fill the List with some values. If I execute the JUnit Test, the values are shown correctly in the Jasper List component. So far so good.

Now I would like to create three textfields in Column Footer band to show the SUM of the values from the List component. Therefore I created  variables named "VAR1", "VAR2", VAR3 and I tried to set the "variable expression"  to $F{currency_1} and for VAR2 $F{currency_2} and for VAR3 $F{currency_3}. In the Column Footer band I placed a textfield and set the expression $V{VAR1}. But this doesn't work. After executing JUnit test I got this:


Caused by: net.sf.jasperreports.engine.design.JRValidationException: Report design not valid :
     1. Field not found : currency_1
    at net.sf.jasperreports.engine.design.JRAbstractCompiler.verifyDesign(JRAbstractCompiler.java:271)
    at net.sf.jasperreports.engine.design.JRAbstractCompiler.compileReport(JRAbstractCompiler.java:153)
    at net.sf.jasperreports.engine.JasperCompileManager.compile(JasperCompileManager.java:241)
    at net.sf.jasperreports.engine.JasperCompileManager.compileReport(JasperCompileManager.java:501)
    at ch.seco.asal.server.service.reports.ReportService.getReport(ReportService.java:140)
    ... 27 more

The variables are not created in the section of the dataset1 it is created in the main / default area.

So, my question here is, how can I access the fields of dataset1 in the "variable expression". Is this possible?

Thanks!

dado77's picture
8
Joined: Aug 25 2014 - 7:04am
Last seen: 4 years 7 months ago

0 Answers:

No answers yet
Feedback