views:

240

answers:

0

We have the following scenario with Jasper reports. It is a complex report with multiple sub-reports, some 3 levels deep. What we want to do is get the current page number, store it in some variable, then render that value in the first page of the report in a text field. Essentially, we want to create a Table of Contents. We have authored a JRScriptlet that pulls the PAGE_NUMBER variable on afterDetailEval and a SECTION_NAME variable (that identifies the TOC section) and stores it in a Map using SECTION_NAME as the key and PAGE_NUMBER as the value; this map is stored in a ThreadLocal variable. Then we have a bunch of text fields in the TOC.jrxml that pulls the page number for a given section from the Map from an expression bound to the relevant text fields. All the text fields have Evaluation Time set to REPORT. We can confirm the scriptlet is properly being invoked but the PAGE_NUMBER is always 1. So the question is, when is the PAGE_NUMBER variable in a given sub-report defined? Any suggestions as to how this could be done?