View Full Version : pageStarted

07-08-2002, 09:26 AM
I'm trying to write a function that sets a field visible only on even pages and have noticed that for a 2 page report the "pageStarted" method is invoked 4 times! with the current page going 1, 2, 1, 1. Why is this?

Is there a document anywhere that details when the various ReportListener methods are called during a report lifecycle?

TIA Graham

07-08-2002, 03:55 PM

the ReportListener interface is currently only used in functions. Functions are called statefull sequential, a functions state is stored (using clone()) and when the report is replayed, the function is restarted from the stored point.

A report is processed at least twice. The first run is the prepare-run, where you can create results reused later (for instance create the total sum of an group to create the percentage or an item in the second run). The prepare run can be tested using the ReportState.isPrepareRun() function. This PrepareRun processes the complete report, but does not output anything on the output target. This run also is used to repaginate the report (e.g. to insert the page states and create the check points used to print pages for the second run.

The second run is not sequential. The report page is initialized using one of the stored check points and processed from that point on. Checkpoints exist for all page starts. From a functions internal point of view, the report processing is like a sequential execution over the complete report, but from outside view, a function can be replayed more than once.

To easily visualize the process, create a simple function, which stores a running number (f.i. the page number) in an vector. Override the clone() method to make sure, that the vector is cloned, when the function itself is cloned, and process the report. Use Vector.toString() as output and print the value.

The result you will get is likely to be something like {1,2}, and next {1} and again {1} for the report you used to test your function.
You wont see printouts like {1,2,1,1}, except when you have forgotten to clone the vector.

The 1,2,1,1 result is easily explained:
{1,2} are likely to be the prepare run, then you printed the first page (to display it in the preview pane) and the second {1} seems to be another printout (a resize of the preview pane or zooming for instance).

A repaginate process is started before a report is printed (when using JFreeReport.printReport()), when the PageFormat changes or (of course) when the previewpane is initialized. Zooming and resizing don't trigger a repaginate, but will cause the current report page to be reprocessed during the printout.

A simple documentation of the function interface can be found in the Interface Function itself. This is currently all the documentation that is available. Another point for the ToDo-List, arggghh :)

Have more fun,
said Thomas