Passing parameters to sub-reports in Jasper
In one of our recent project, we made quite a good use of Grails Jasper plugin (v-0.9.7) to generate reports in the form of PDFs and Excel sheets. The reports contain sub-reports, which in many cases, contain sub-reports again. The way to pass parameters to sub-reports at the deeper level is to use the following tag in the .jrxml file: <subreportParameter>
In the Grails Jasper plugin, the Jasper controller searches for the “SUBREPORT_DIR” in the params when the request is forwarded to it. If it does not find any key named “SUBREPORT_DIR” in the params map, it initializes the variable SUBREPORT_DIR with the value of “jasperFilePath” i.e. the location where the Jasper’s .jasper and .jrxml files can be found. Now suppose you want to give seperate file location for your sub-reports, you can easily do this using the following code in the .jrxml file inside the tag:
... ...
Note the value of “![CDATA[$P{SUBREPORT_DIR}]]” parameter can be passed as a parameter from the controller to the master report but afterwards you can make use of the tag to pass on the information to the subsequent sub-reports to any level.
For more information on the jasper .jrxml tags, please visit the following link here:
Hope this helps !!
– Abhishek Tejpaul
abhishek@intelligrape.com
[IntelliGrape Software Pvt. Ltd]
This info is outstanding! I’m fairly new to serch engine optimization so any help is much appreciated.