Class Jasperreport

All Implemented Interfaces:
Serializable, Cloneable, Component, Scope, ComponentCtrl

public class Jasperreport extends Iframe
The JasperReport component. It is used to generate a Jasper report into an inline frame.

Available in ZK PE and ZK EE.

Note: this component is serializable only if the data source (getDatasource()) is serializable.

Since:
3.0.2
Author:
gracelin
See Also:
  • Constructor Details

    • Jasperreport

      public Jasperreport()
    • Jasperreport

      public Jasperreport(String src)
  • Method Details

    • getSrc

      public String getSrc()
      Returns the source (jasper file).
      Overrides:
      getSrc in class Iframe
      Returns:
      src The compiled file (jasper file).
    • setSrc

      public void setSrc(String src)
      Sets the source (jasper file).

      If src is changed, the whole component is redrawn.

      Overrides:
      setSrc in class Iframe
      Parameters:
      src - The compiled file (jasper file). If null or empty, nothing is included.
      See Also:
    • setContent

      public void setContent(Media media)
      Sets the content directly.

      Default: null.

      Calling this method implies setSrc(null). In other words, the last invocation of setContent(org.zkoss.util.media.Media) overrides the previous setSrc(java.lang.String), if any.

      Overrides:
      setContent in class Iframe
      Parameters:
      media - the media to display.
      Since:
      5.0.0
      See Also:
    • getParameters

      public Map<String,Object> getParameters()
      Returns the JasperReports Parameters.

      Default: null.

    • setParameters

      public void setParameters(Map<String,Object> parameters)
      Sets the JasperReports Parameters. To provide exporter parameters, include an entry with key "exportParameter" and value as another parameter Map. For example:
      
              String key = JRXlsAbstractExporterParameter.PROPERTY_ONE_PAGE_PER_SHEET.toString();
              Map parameters = new HashMap();
              Map exportParams = new HashMap();
              exportParams.put(key, false);
              parameters.put("exportParameter", exportParams);
              report.setParameters(parameters);
               
      Parameters:
      parameters - use to fill the report
    • setHibernate

      public void setHibernate(boolean hibernate)
      Sets whether enable the hibernate data source.
      Since:
      5.0.1
    • isHibernate

      public boolean isHibernate()
      Returns whether enable the hibernate data source.

      Default: false

      Since:
      5.0.1
    • getDatasource

      public net.sf.jasperreports.engine.JRDataSource getDatasource()
      Returns the JasperReports DataSource.

      Default: null.

    • setDatasource

      public void setDatasource(net.sf.jasperreports.engine.JRDataSource dataSource)
      Sets the JasperReports DataSource.
      Parameters:
      dataSource - use to fill the report
    • setDataConnection

      public void setDataConnection(Connection connection)
      Sets the JasperReports Data Connection.
      Parameters:
      connection - use to fill the report
      Since:
      5.0.1
    • getDataConnection

      public Connection getDataConnection()
      Returns the JasperReports Data Connection.

      Default: null

      Since:
      5.0.1
    • getType

      public String getType()
      Returns the output file type.

      Default: pdf.

      Since:
      3.0.3
    • setType

      public void setType(String type)
      Sets the output file type. Allowed type: pdf, xml, html, rtf, xls, jxl, csv and odt.
      pdf
      The PDF format.
      rtf
      The RTF format (Rich Text Format).
      xls
      The Microsoft Excel format generated with Apache POI.
      jxl
      The Microsoft Excel format generated with JExcelApi.
      csv
      The CSV format (Comma-Separated Values)
      odt
      The OpenOffice Writer format
      Parameters:
      type - type of output file. If type is null, assign it a default value "pdf".
      Since:
      3.0.3
    • getLocale

      public Locale getLocale()
      Returns the output file locale.

      Default: null (means the ZK default, Locales.getCurrent())).

      getLocale() getParameters() with a value
      associated with JRParameter.REPORT_LOCALE
      What is used
      XignoredX
      nullYY
      nullnullLocales.getCurrent()
      Since:
      3.0.4
    • setLocale

      public void setLocale(Locale locale)
      Sets the output file locale.
      Parameters:
      locale - the locale. If null, the ZK default is used (Locales.getCurrent()).
      Since:
      3.0.4
      See Also:
    • getExportName

      public String getExportName()
      Returns the export file name for the download if any, the full name will be exportName + "." + format. Note: exportName can not be empty or null. Default: "report".
      Returns:
      export file name
      Since:
      8.6.1
    • setExportName

      public void setExportName(String exportName)
      Sets the export file name for the download if any, the full name will be exportName + "." + format. Note: exportName can not be empty or null.
      Parameters:
      exportName - the export file name
      Throws:
      IllegalArgumentException - if exportName is empty or null.
      Since:
      8.6.1
    • setJasperreporteExporterFactory

      public void setJasperreporteExporterFactory(JasperreportExporterFactory factory)
      Set the factory to use your own exporter, reference to JasperreportExporterFactory
      Parameters:
      factory -
    • setJasperreporteExporterFactory

      Parameters:
      clsnm -
      Throws:
      NoSuchMethodException
      InstantiationException
      InvocationTargetException
      ClassNotFoundException
      IllegalAccessException
      Since:
      5.0.8
      See Also:
    • getJasperreporteExporterFactory

      public JasperreportExporterFactory getJasperreporteExporterFactory()
    • getEncodedSrc

      protected String getEncodedSrc()
      Description copied from class: Iframe
      Returns the encoded src (Iframe.getSrc()).
      Overrides:
      getEncodedSrc in class Iframe
    • getExtraCtrl

      public Object getExtraCtrl()
      Description copied from class: HtmlBasedComponent
      Returns the client control for this component. It is used only by component developers.

      Default: creates an instance of HtmlBasedComponent.ExtraCtrl.

      Specified by:
      getExtraCtrl in interface ComponentCtrl
      Overrides:
      getExtraCtrl in class Iframe
      Returns:
      null if no special handling required. If the component requires some special controls, it could return an object that implements one or several interfaces in the org.zkoss.zk.ui.ext.render package. For example, Cropper.
      See Also:
    • getReport

      public Media getReport()
      Returns a AMedia contains report's byte stream.
      Since:
      6.0.0
    • renderProperties

      protected void renderProperties(ContentRenderer renderer) throws IOException
      Description copied from class: HtmlBasedComponent
      Renders the content of this component, excluding the enclosing tags and children.

      See also ZK Client-side Reference: Property Rendering

      Overrides:
      renderProperties in class Iframe
      Throws:
      IOException