Class ElementKeyExporterFilter

java.lang.Object
net.sf.jasperreports.engine.export.ElementKeyExporterFilter
All Implemented Interfaces:
ExporterFilter

public class ElementKeyExporterFilter extends Object implements ExporterFilter
An exporter filter that excludes elements based on their keys. The filter uses a fixed set of elements keys to exclude.

Element keys are set at report design time and are propagated into generated reports. Each element in a filled report has the same key as the element from the report template that generated it.

To trigger an element key filter, the report designer needs to define one or more report properties that start with <exporter_property_prefix>.exclude.key. Each such property matches a single element key which is to be excluded by the filter. The element key is given by the property value, or if no value is set for the property, by the property suffix.

The following example shows how to specify element keys which are to be excluded from specific export outputs:

 <jasperReport ...>
   <!-- exclude elements with keys Image1 and Text4 from HTML export -->
   <property name="net.sf.jasperreports.export.html.exclude.key.Image1"/>
   <property name="net.sf.jasperreports.export.html.exclude.key.Text4"/>
   <!-- exclude elements with keys Image5 from PDF export -->
   <property name="net.sf.jasperreports.export.pdf.exclude.key.the.image" value="Image5"/>
   ...
 </jasperReport>
 
Author:
Lucian Chirita (lucianc@users.sourceforge.net)
  • Field Details

    • EXCEPTION_MESSAGE_KEY_EXCLUDED_NULL_KEYS_SET

      public static final String EXCEPTION_MESSAGE_KEY_EXCLUDED_NULL_KEYS_SET
      See Also:
  • Constructor Details

    • ElementKeyExporterFilter

      public ElementKeyExporterFilter(Set<String> excludedKeys)
      Creates a filter instance.
      Parameters:
      excludedKeys - the set of keys to exclude
  • Method Details

    • isToExport

      public boolean isToExport(JRPrintElement element)
      Excludes elements whose keys match any of the excluded keys. Elements with no keys are not excluded.
      Specified by:
      isToExport in interface ExporterFilter