JFreeReport Documentation
Introduction
JFreeReport is a successful embedded reporting engine. By providing a high degree of flexibility and minimal requirements for the execution environment, JFreeReport can be integrated into most programms with little effort.
...
Historical Note: The classical report process
The Layout oriented Reporting Process
JFreeReport 0.9 uses a completely different reporting approach. Instead of using the data as control factor for the report process, JFreeReport concentrates on the layout that should be generated. In the new model, JFreeReport iterates over the layout (the report definition). The data processing is controlled by embedded data control commands, which control the iteration over the data sources.
By concentrating on the desired output format, now it is realitivly easy to create reports, which are no longer bounds to the classical nested grouping structures. Groups are controlled by the defined data commands, and therefore it is possible to create paralell or even irregular grouping structures.
...
Flow control and available operations
The implemented default behaviour of the Report-Elements
Introduction
JFreeReport as an engine is not bound to a specific processing model. The LayoutControllers we use define a very abstract processs model, in common words, their interface says, that they do some work, but it does not state how they do the work and what object types might be the base for their work. JFreeReport's default processing model is called the 'Flow-Modell'. When describing how JFreeReport processes content and how the data and layout layer interact with each other, we will use that Flow-Modell as reference.
A report model is a system of report elements and their behaviour. JFreeReport offers a general framework for implementing report models. A report model has to cope with two general tasks: (1) To process the report structure and (2) to update or process the data for the report. There are only a limited number of operations one can do to the data-set. As this data processing can be broken down into relatively fixed tasks, the engine provides a fine grained library of functions which should cover all current and future needs of data processing.
Elements of the flow model
The default flow model is a very minimalistic (yet still complete) reporting model. The model is built on the idea, that a report definition and its structural dependencies can be seen as some sort of content and processing description language. Each node in the tree represents specific layout and data processing instructions. Iterating the report definition (the instruction tree) drives the report processing. Once the tree is fully processed, the reporting is finished. Reporting is a highly iterative process: the same itemband is printed several times (but each time with new data, of course). The flow modell follows this approach by introducing repeatable nodes. These nodes can (depending on certain conditions) be repeatedly iterated. The 'flow-modell' uses a DOM tree to describe the report content. The tree consists of several Node types.
- Static-Text
- Content-Element
- Sections
- Group
- Detail-Section
- Sub-Report
- Report
Static Text
Static text is immutable text content. This node type cannot have attributes or styles. When layouting, text nodes always inherit the style from their parent node.
Element Types
Elements are nodes that can have attributes and style. Contrary to the XML-DOM model, elements cannot have child nodes by default. Elements can have named expressions and functions. Named expressions get added to the global data-row and can be accessed from other expressions and functions by their name. Once the element goes out of scope, these expressions get removed from the data-row.
Attributes and styles can be computed at runtime. For this purpose, the Element class provides Style- and Attribute-Expression slots. The evaluation result of these expressions will be set as attribute. Attributes computed from expressions override any previously defined attribute on the element. Style properties computed from expressions override any previously declared style, no matter whether the style is static or computed indirectly by an attribute expression.
All elements can have a display-condition. A display condition is an anonymous expression. If that condition returns false, the element will be ignored for the processing. Display conditions are evaluated before the element's expressions get activated, so they have no access to any of these expressions. The display condition for the root element is ignored.
Content-Element
Content-Elements are mutable content. The element cannot have static children. The element's contents are read from a 'Value-Expression'. The 'Value-Expression' is an ordinary, anonymous and stateless expression that cannot be precomputed.
Flow-Behaviour
If the 'Value-Expression' returns a Node on evaluation, the node is inserted into the Document-Tree as if it were a direct child of the content element. The report processing continues with that returned element.
The 'LibLayout' report target treats the evaluation result as a special attribute and forwards this attibute along with all known meta-data to the layouting layer. The content can be formated or processed using the style rule system.
Section
A section is an element that can contain child nodes.
Sections can have flow operations defined. These flow operations can either be executed before the element is processed (and thus before any of the expressions gets activated, but after the display condition is evaluated) or after the element is fully processed.
Flow-Behaviour
If a section is marked as repeatable section, the layout controller has the choice to reprocess the contents of the section. The section will be repeated, if an advance has been requested and the data-row is advancable (there is a next row). By binding the repeatability of sections to the data-row, we effectivly prevent infinite loops caused by invalid expressions or other definitions.
If the section is contained in a group, the group's grouping expression will be evaluated. If the grouping expression indicates that the processing should stop (by returning 'true'), the section will not be repeated. If the expression indicates that the grouping should continue, the next sub-group is queried until all groups declare that they want to repeat the section.
If the layout controller decides to repeat the section, the 'advance' request will be commited and the cursor of the data-row is shifted to the next row. (A manual commit can be triggered by adding a 'Commit'-flow operation to any of the section's queues.) After that, the section is fully processed again.
Named expressions on a repeatable section go out-of scope and get readded as fresh instances on each iteration.
Group
A group is a section that has a grouping expression. Groups are repeatable by default.
Flow-Behaviour
If the group is repeatable, the repeat-test described above will use the parent group as first test for repeatability. The group's grouping expression will be ignored for that matter.
Detail-Section
The detail band is a ordinary band with no extra properties. It is repeatable by default and contains an 'Advance' Flow-Operation in its postprocessing queue. The main purpose of the Detail-Section is to provide some familiar elements for all users who are used to the old reporting engines.
JFreeReport
This is the first element of all report processings. The JFreeReport object holds several global objects, which influence the whole report processing.
- Data-Factory and the initial Query
- Input-Parameters
- The Style-Sheet collection
- The report configuration and the localization support
- The data-factory is a generic interface to query data-sources. The query-string and the given input-parameters are used for the query operation.
- The input parameters are a plain collection of objects. These parameters are accessible through the global DataRow.
- The (possibly empty) style-sheet collection is passed on to the layouting layer.