Jump to content
We've recently updated our Privacy Statement, available here ×

Repeatable subreport; datasource as report field.


jan.du.toit
Go to solution Solved by lucianc,

Recommended Posts

Hi.

I have the following combination of reports and datasources:


Compiled Jasper Report named "ReportTemplateA", which is filled by custom JRDataSource named "DSA". Using "ReportTemplateA" with "DSA" works fine. But "ReportTemplateA" is usually used as a subreport within another report named "ReportTemplateB" - in this instance the subreport A is placed within the 'detail' report section of eport B. "ReportTemplateB" is also filled by a custom JRDataSource named "DSB". "DSB" is just a collection of datasources of type "DSA". The 'data source expression' for the subreport "ReportTemplateA" is that of a report field named "dSource".


Now, for example, when filling "ReportTemplateB" with a "DSB" which consists of 10 "DSA" then the "dSource" field is pulled correctly 10 times from "DSB" and in each case the correct "DSA" is returned. But the sub-report is only filled/displayed once with the data of the first "DSA" returned as a field "dSource" from "DSB". What I need is the sub-report to be created/filled 10 times with the 10 datasources returned by the report field. Other report elements within the 'detail' report section of "ReportTemplateB" gets displayed correctly 10 times, but their is no sub-report for 9 of them.


This should be no issue right? And is supported by JR? Maybe, I'm just doing something wrong? Can anybody please shed some light on this?


Thanks in advance.
Regards, Jan.

Link to comment
Share on other sites

  • Replies 9
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Performed more debugging... It seems like the sub-report is indeed filled the correct amount of times according to the amount of "DSA"s within "DSB". Thus in our example above the subreport is filled 10 times, thus being displayed 10 times correctly. The problem is that the same data source is passed each time to fill the subreport, that is the first "DSA" retrieved as a field from "DSB" is used each and everytime to fill the subreport. Obviously the datasource is at its end causing it to seem as if the other 9 subreports are not filled.

 

 

When I printout the "dSource" field [$F{dSource}]within the main report (ReportTemplateA) it is different, thus the data source "DSB" correctly feeds ReportTemplateA. But when this field is passed as a datasource to fill the subreport then the first $F{dSource} value is passed along each and everytime. I have the data source expression for the subreport as $F{dSource}

 

Is this the expected behaviour? Please, can somebody enlighten this matter.

 

Thank you very much.

Regards, Jan.

Link to comment
Share on other sites

Is there any way we could reproduce this?

 

$F{dSource} should always yield the value corresponding to the current record, and I've never heard before of a case in which it would always yield the value corresponding to the first record.

 

Regards,

Lucian

Link to comment
Share on other sites

It is as you said the value $F{dSource} is correct and it corresponds to the current record. I can see this when I print the string representation of $F{dSource} (which is Object.toString's objectname@hascode), thus the value of $F{dSource} is read correctly each time for each record, but when I feed the field value as a datasource to the subreport then the first value of $F{dSource} is always passed to my subreport for each record.

 

As far as reproducibility goes, I think it will be best if I give the jrxml files and the custom datasources. But I will obviously need to take my code and create a little "foo bar" type of example from it first, in order not to breach any non-disclosure issues.

Link to comment
Share on other sites

  • Solution

The following line in the master report causes the subreport data source mixup:

Code:
[/code]			


Could you change it to

Code:
[/code]			

and see whether the issue is fixed?

Directly passing $P{REPORT_PARAMETERS_MAP} as subreport parameters map has been dangerous because the parameters map is altered by the subreport. Cloning the map should fix the issue as the map would no longer be shared by several subreports.

Regards,
Lucian

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...