Servoy Jasper Reports

(plugins.jasperReports)

Overview

This class serves as the primary implementation for managing JasperReports in a Servoy application. It provides functionalities for report generation, data source handling, file operations, and export customization. Using these, developers can seamlessly integrate JasperReports into Servoy projects for dynamic report creation and management. ## Key Functionalities The class facilitates running reports with various data sources and input types, including databases, XML, and CSV. Developers can define input and output parameters, customize locales, and specify the output format using predefined constants. File operations are supported for reading, writing, and deleting report files on the server. Reports can be compiled from .jrxml files to .jasper format for optimized performance. Additionally, the class includes methods for retrieving available reports, merging multiple reports, and accessing or modifying report parameters. The class also supports viewing, printing, and exporting reports in multiple formats such as PDF, HTML, Excel, and XML. Export options include setting custom parameters for advanced use cases, like embedding metadata or adjusting resource paths for specific output types. Advanced features include handling viewer configurations, moving table-of-content pages, and merging reports with consistent styles and orientations. Developers can also use locale-based i18n integration to produce reports in different languages. For external library dependencies, see https://community.jaspersoft.com/wiki/jasperreports-library-requirements.

Returned Types

INPUT_TYPE,OUTPUT_FORMAT,JR_SVY_VIEWER_DISPLAY_MODE,

Properties Summarized

Type
Name
Summary

Get the version of the Servoy JasperReports Plugin.

Property for retrieving and setting the paths to the extra resources directories.

Property for retrieving and setting the path to the reports directory, set by the current client, relative to the server reports directory.

Property used in order to get or set the Jasper Viewer's export formats.

Sets or gets the Jasper Viewer's icon URL.

Sets or gets the Jasper Viewer's title text.

Methods Summarized

Type
Name
Summary

Compile a Jasper Reports .

Delete a report file from the Server.

Retrieve a JSDataSet with the report parameters, except the system defined ones.

Retrieve a String array of available reports, based on the reports directory.

Retrieve a String array of available reports, based on the reports directory.

Function to merge two or more reports into a single report file.

Retrieve a report file from the Server.

This method runs a specified (client) report according to the output format, parameters and locale.

This method runs a specified (client) report according to the output format, parameters and locale.

This method runs a specified (client) report according to the output format, parameters and locale.

This method runs a specified (client) report according to the output format, parameters and locale.

This method runs a specified (client) report according to the output format, parameters and locale.

This method runs a specified (client) report according to the output format, parameters and locale.

Store a reportFile on the Server.

Properties Detailed

pluginVersion

Get the version of the Servoy JasperReports Plugin.

Type String the plugin's version

Sample

relativeExtraDirectories

Property for retrieving and setting the paths to the extra resources directories. The paths are set per client and are relative to the server corresponding directories setting.

By default the value is read from the Admin Page: Server Plugins - the directories.jasper.extra property. If the client modifies the default property, this value will be used instead of the default one for the whole client session and only for this client. Each client session has it's own extraDirectories value.

NOTE: Extra directories are not searched recursively.

Type String the path to the extra directories relative to the server side set location

Sample

relativeReportsDirectory

Property for retrieving and setting the path to the reports directory, set by the current client, relative to the server reports directory.

By default the value is read from the admin page Server Plugins, the directory.jasper.report property. If no value has been set in the admin page for the report directory, the default location will be set to /path_to_install/application_server/server/reports. A client is only able to set a path relative to the server report directory. If the client modifies this property, its value will be used instead of the default one, for the whole client session and only for this client. Each client session has it's own relativeReportDirectory value.

Type String the location of the reports directory, relative to the server set path

Sample

viewerExportFormats

Property used in order to get or set the Jasper Viewer's export formats.

Type Array the list of desired export formats; the first one will be the default export format.

Sample

viewerIconURL

Sets or gets the Jasper Viewer's icon URL.

Type String

Sample

viewerTitle

Sets or gets the Jasper Viewer's title text.

Type String

Sample

Methods Detailed

compileReport(report)

Compile a Jasper Reports .jrxml file to a .jasper file.

Parameters

  • String report the .jrxml jasper report file

Returns: Boolean the compiled jasper report file

Sample

compileReport(report, destination)

Compile a Jasper Reports .jrxml file to a .jasper file.

Parameters

  • String report the .jrxml jasper report file

  • String destination the destination file for the compiled report

Returns: Boolean the compiled jasper report file

Sample

deleteFileFromReportsDir(fileName)

Delete a report file from the Server.

Parameters

  • String fileName the name of the report file to delete

Returns: Boolean true if the file was successfully deleted, false otherwise

Sample

getReportParameters(report)

Retrieve a JSDataSet with the report parameters, except the system defined ones.

Parameters

  • String report the name of the report file to get the parameters for

Returns: JSDataSet the JSDataSet with the report parameters

Sample

getReports()

Retrieve a String array of available reports, based on the reports directory.

Returns: Array the String array of available reports

Sample

getReports(filter)

Retrieve a String array of available reports, based on the reports directory.

Parameters

  • String filter the string to be used as a search filter

Returns: Array the String array of available reports

Sample

mergeJasperPrint(printList, orientation, outputType, outputOptions, localeString)

Function to merge two or more reports into a single report file. The reports to merge must have been previously exported as JRPRINTs.

Parameters

  • Array printList the list of reports to merge; the objects in the list must be jasperPrint objects (or reports exported as jasper print)

  • String orientation the orientation of the result report

  • String outputType the output type of the result report

  • Object outputOptions the output options of the report, as provided for the runReport function

  • String localeString localeString the string which specifies the locale

Returns: Object the result report as an Object

Sample

readFileFromReportsDir(fileName)

Retrieve a report file from the Server.

Parameters

  • String fileName the name of the file to read from the reports directory

Returns: Array the report file retrieved as a byte array

Sample

runReport(reportDataSource, report, outputOptions, outputType, parameters)

This method runs a specified (client) report according to the output format, parameters and locale. If using a table of contents and if needed, the table of contents can be moved to a specified page. Please refer to the sample code for more details.

Parameters

  • Object reportDataSource the server name or foundset to run the report on

  • String report the report file (relative to the reports directory)

  • Object outputOptions the output file (must specify an absolute path) or null if not needed

  • String outputType the output format; use the constants node for available output formats

  • Object parameters a parameter map to be used when running the report

Returns: Array the generated reported as a byte array

Sample

runReport(reportDataSource, report, outputOptions, outputType, parameters, localeString)

This method runs a specified (client) report according to the output format, parameters and locale. If using a table of contents and if needed, the table of contents can be moved to a specified page. Please refer to the sample code for more details.

Parameters

  • Object reportDataSource the server name or foundset to run the report on

  • String report the report file (relative to the reports directory)

  • Object outputOptions the output file (must specify an absolute path) or null if not needed

  • String outputType the output format; use the constants node for available output formats

  • Object parameters a parameter map to be used when running the report

  • String localeString the string which specifies the locale

Returns: Array the generated reported as a byte array

Sample

runReport(reportDataSource, report, outputOptions, outputType, parameters, localeString, moveTableOfContent)

This method runs a specified (client) report according to the output format, parameters and locale. If using a table of contents and if needed, the table of contents can be moved to a specified page. Please refer to the sample code for more details.

Parameters

  • Object reportDataSource the server name or foundset to run the report on

  • String report the report file (relative to the reports directory)

  • Object outputOptions the output file (must specify an absolute path) or null if not needed

  • String outputType the output format; use the constants node for available output formats

  • Object parameters a parameter map to be used when running the report

  • String localeString the string which specifies the locale

  • Boolean moveTableOfContent true in order to move the table of contents, false otherwise

Returns: Array the generated reported as a byte array

Sample

runReport(inputType, reportDataSource, inputOptions, report, outputOptions, outputType, parameters)

This method runs a specified (client) report according to the output format, parameters and locale. If using a table of contents and if needed, the table of contents can be moved to a specified page. Please refer to the sample code for more details.

Parameters

  • String inputType the type of the datasource, as one of the constants in INPUT_TYPE

  • Object reportDataSource the server name or foundset to run the report on

  • String inputOptions additional input options (e.g. which node to iterate in the xml datasource document)

  • String report the report file (relative to the reports directory)

  • Object outputOptions the output file (must specify an absolute path) or null if not needed

  • String outputType the output format; use the constants node for available output formats

  • Object parameters a parameter map to be used when running the report

Returns: Array the generated reported as a byte array

Sample

runReport(inputType, reportDataSource, inputOptions, report, outputOptions, outputType, parameters, localeString)

This method runs a specified (client) report according to the output format, parameters and locale. If using a table of contents and if needed, the table of contents can be moved to a specified page. Please refer to the sample code for more details.

Parameters

  • String inputType the type of the datasource, as one of the constants in INPUT_TYPE

  • Object reportDataSource reportDataSource the server name or foundset to run the report on

  • String inputOptions additional input options (e.g. which node to iterate in the xml datasource document)

  • String report the report file (relative to the reports directory)

  • Object outputOptions the output file (must specify an absolute path) or null if not needed

  • String outputType the output format; use the constants node for available output formats

  • Object parameters a parameter map to be used when running the report

  • String localeString a string which indicates the locale

Returns: Array the generated reported as a byte array

Sample

runReport(inputType, reportDataSource, inputOptions, report, outputOptions, outputType, parameters, localeString, moveTableOfContent)

This method runs a specified (client) report according to the output format, parameters and locale. If using a table of contents and if needed, the table of contents can be moved to a specified page. Please refer to the sample code for more details.

Parameters

  • String inputType the type of the datasource, as one of the constants in INPUT_TYPE

  • Object reportDataSource the server name or foundset to run the report on

  • String inputOptions additional input options (e.g. which node to iterate in the xml datasource document)

  • String report the report file (relative to the reports directory)

  • Object outputOptions the output file (must specify an absolute path) or null if not needed

  • String outputType the output format; use the constants node for available output formats

  • Object parameters a parameter map to be used when running the report

  • String localeString a string which indicates the locale

  • Boolean moveTableOfContent true in order to move the table of contents, false otherwise

Returns: Array the generated reported as a byte array

Sample

writeFileToReportsDir(fileName, obj)

Store a reportFile on the Server.

Parameters

  • String fileName the name of the file to write to

  • Object obj the object file to write

Returns: Boolean true if the write was successful, false otherwise

Sample


Last updated

Was this helpful?