Interface JRSection

  • All Superinterfaces:
    Cloneable, JRCloneable
    All Known Implementing Classes:
    JRBaseSection, JRDesignSection, JRFillSection

    public interface JRSection
    extends JRCloneable
    Implementations of this interface represent various sections in the report template.

    Report Sections

    JasperReports works with templates that are structured into multiple sections, like any traditional reporting tool. A report can contain the following sections: background, title, summary, page header, page footer, last page footer, column header and column footer. For each group defined in the report, there is a corresponding group header section and group footer section.

    At report-filling time, the engine iterates through the virtual records of the supplied report data source and renders each report section when appropriate, depending on each section's defined behavior.

    For instance, the detail section is rendered for each record in the data source. When page breaks occur, the page header and page footer sections are rendered as needed.

    Sections are made of one or more bands. Bands are portions of the report template that have a specified height and width and can contain report elements like lines, rectangles, images, and text fields. These bands are filled repeatedly at report-generating time and make up the final document.

    The entire structure of the report template is based on the following sections: <title>, <pageHeader>, <columnHeader>, <groupHeader>, <detail>, <groupFooter>, <columnFooter>, <pageFooter>, <lastPageFooter>, <summary>, <background> and <noData>. All report sections are optional, but of course all useful templates must have at least one such section.

    Title

    This is the first section of the report. It is generated only once during the report-filling process and represents the beginning of the resulting document.

    The title section precedes even the page header section. To print the page header before the title section, put the elements on the page header at the beginning of the title section as well. One can suppress the actual page header on the first page using the <printWhenExpression>, based on the PAGE_NUMBER report variable.

    The title section can be followed by a page break if the isTitleNewPage attribute at report level is set to true.

    Page Header

    This section appears at the top of each page in the generated document.

    Column Header

    This section appears at the top of each column in the generated document.

    Detail

    For each record in the data source, the engine tries to generate this section. The detail section can be made of multiple bands.

    Column Footer

    This section appears at the bottom of each column in the generated document. It never stretches downward to acquire the content of its containing text fields. Its rendering position is controlled by the isFloatColumnFooter flag declared at report template level.

    Page Footer

    This section appears at the bottom of each page in the generated document. Just like the column footer section, the page footer never stretches downwards to acquire the content of its containing text fields and always retains the declared fixed height.

    Summary

    This section is generated only once per report and appears at the end of the generated document, but is not necessarily the last section generated. This is because in some cases the column footer and/or page footer of the last page follows it.

    One can have the summary section start a new page of its own by setting the isSummaryNewPage attribute to true at report template level. Even if this attribute remains false, the summary section always starts a new page if it does not fit on the remaining space of the last page, or if the report has more than one column and it has already started a second column on the last page.

    Last Page Footer

    If present, this section replaces the normal page footer section, but only on the last occurrence of the page footer, which might not be the last page if the summary is present and it overflows on multiple pages or it is rendered alone on its own last page. So it behaves more like the last page footer than the footer of the last page.

    Background

    This is a special section that is rendered on all pages and its content placed underneath all other report sections. Normal report sections are rendered one after the other, but the background section does not interfere with the other report sections and can be used to achieve watermark effects or to create the same background for all pages.

    No Data

    This is another special section that is generated only once per report and, under certain conditions, its content will replace all the ordinary report's content.

    Sometimes when the report data source is empty, is very useful to generate an equivalent content, a notice, maybe, or an image, in order to replace all the empty zone. Especially in the case of subreports, more useful is to replace all the subreport's content with an equivalent one.

    If the <noData> section is defined in the report template, and if the data source is empty, then the <noData> section will be the only one taken into account at fill time, and its content will produce the report output.

    Group Header

    This section marks the start of a new group in the resulting document. It is inserted in the document every time the value of the group expression changes during the iteration through the data source. The group header section is a multi-band section.

    Group Footer

    Every time a report group changes, the engine adds the corresponding group footer section before starting the new group or when the report ends. The group footer section is also a multi-band section.
    Author:
    Teodor Danciu (teodord@users.sourceforge.net)
    See Also:
    JRBand
    • Method Detail

      • getBands

        JRBand[] getBands()
        Returns the bands within the current section.
      • getParts

        JRPart[] getParts()
        Returns the parts within the current section.