How to pass List component values from subdataset to main dataset


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". 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: Report design not valid :
     1. Field not found : currency_1
    at net.sf.jasperreports.engine.JasperCompileManager.compile(
    at net.sf.jasperreports.engine.JasperCompileManager.compileReport(
    at ch.seco.asal.server.service.reports.ReportService.getReport(
    ... 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?


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

0 Answers:

No answers yet