JasperReportsServoyViewer

(beans.jasperReportsServoyViewer)

Overview

The JasperReportsServoyViewer is a Servoy bean designed to embed and display JasperReports within Servoy applications. It provides scripting capabilities for customizing visual properties such as background, foreground, font, size, and borders. The bean integrates with the JasperReportsProvider to support dynamic report viewing and customization. ## Functionality Reports can be rendered and displayed using the js_showReport method, which accepts parameters such as data source, report file, and locale. The viewer supports various export formats, configurable through scripting. The bean also facilitates managing paths for report directories and extra resource directories, ensuring integration with the JasperReports plugin. The JRViewer wrapper enables fine-tuned control of the viewer’s display behavior and export functionality.

Properties Summarized

Type
Name
Summary

Sets or gets the background color of the Bean.

This is a readonly property which returns the bean version.

Gets or gets the file save/export formats of the Bean's viewer.

Sets or gets the border type, width and color.

Sets or gets the font type of the Bean's viewer.

Sets or gets the foreground color.

Gets or sets the name of the Bean.

Get or set the relative path or comma separated paths to the extra resource directories of the Servoy JasperReports plugin.

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

Methods Summarized

Type
Name
Summary

Gets the height of the Bean.

Gets the x-coordinate of the Bean's top-left corner location.

Gets the y-coordinate of the Bean's top-left corner location.

Gets the width of the Bean.

void

Sets the size of the Bean.

void

Shows the indicated report in a JasperReports Viewer (in the Bean).

void

Shows the indicated report in a JasperReports Viewer (in the Bean).

void

Shows the indicated report in a JasperReports Viewer (in the Bean).

Properties Detailed

background

Sets or gets the background color of the Bean.

Type String the border color of the bean

Sample

myElement.background='#00ff00';

beanVersion

This is a readonly property which returns the bean version. The bean version indicates which version of the Servoy JasperReports plugin the bean should be used with.

Type String the version of the bean; this should be in sync with the version of the plugin used

Sample

application.output(myElement.beanVersion);

beanViewerExportFormats

Gets or gets the file save/export formats of the Bean's viewer.

Type Array the file save/export formats of the viewer

Sample

//also see plugins.jasperReports.viewerExportFormats
myElement.beanViewerExportFormats=[OUTPUT_FORMAT.PDF, OUTPUT_FORMAT.XLS];

border

Sets or gets the border type, width and color.

Type String border type, width and color

Sample

myElement.border='LineBorder,4,#000000';

displayMode

Type String the display mode of the viewer

Sample

myElement.displayMode = JR_SVY_VIEWER_DISPLAY_MODE.FIT_WIDTH;
myElement.showReport(myDataSource,"myReport.jrxml",null);

font

Sets or gets the font type of the Bean's viewer.

Type String the font type used in the viewer

Sample

myElement.font='Tahoma,0,14';

foreground

Sets or gets the foreground color.

Type String the foreground color

Sample

myElement.foreground='#000000';

name

Gets or sets the name of the Bean.

Type String the name of the Bean

Sample

var beanName = myElement.name;

relativeExtraDirectories

Get or set the relative path or comma separated paths to the extra resource directories of the Servoy JasperReports plugin. The paths are set per client and are relative to the server corresponding directories setting.

Please refer to the same property of the Servoy JasperReports plugin for more details.

Type String the relative path or paths to the client set extra directory/directories

Sample

myElement.extraDirectories='relative/path/to/client/extraDirectory1';

relativeReportsDirectory

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

Please refer to the same property of the Servoy JasperReports plugin for more details.

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

Sample

myElement.relativeReportsDirectory = 'relativePath/to/serverReportsDirectory';

transparent

Type Boolean

Methods Detailed

getHeight()

Gets the height of the Bean.

Returns: Number the height of the Bean

Sample

var h = myElement.getHeight();

getLocationX()

Gets the x-coordinate of the Bean's top-left corner location.

Returns: Number the x-coordinate of the Bean's top-left corner location

Sample

var x = myElement.getLocationX();

getLocationY()

Gets the y-coordinate of the Bean's top-left corner location.

Returns: Number the y-coordinate of the Bean's top-left corner location

Sample

var y = myElement.getLocationY();

getWidth()

Gets the width of the Bean.

Returns: Number the width of the Bean

Sample

var w = myElement.getWidth();

setLocation(x, y)

Parameters

Returns: void

setSize(width, height)

Sets the size of the Bean.

Parameters

  • Number width the width of the bean

  • Number height the height of the bean

Returns: void

Sample

myElement.setSize(800,600);

showReport(source, report, parameters)

Shows the indicated report in a JasperReports Viewer (in the Bean).

Parameters

  • Object source the datasource (the server name, foundset or dataset) to run the report on

  • String report the report file to export and preview (relative to the reports directory)

  • Object parameters the map of parameters to be used when previewing the report

Returns: void

Sample

var params = new Object();
params.SUBREPORT_DIR = "./Subreport_Tests/";
var report = myElement.showReport(customers_to_orders,"/Subreport_Tests/main_report_fs.jrxml",params);

showReport(source, report, parameters, localeString)

Shows the indicated report in a JasperReports Viewer (in the Bean).

Parameters

  • Object source the datasource (the server name, foundset or dataset) to run the report on

  • String report the report file to export and preview (relative to the reports directory)

  • Object parameters the map of parameters to be used when previewing the report

  • String localeString the string which specifies the locale

Returns: void

Sample

var params = new Object();
params.SUBREPORT_DIR = "./Subreport_Tests/";
var report = myElement.showReport(customers_to_orders,"/Subreport_Tests/main_report_fs.jrxml",params);

showReport(source, report, parameters, localeString, moveTableOfContent)

Shows the indicated report in a JasperReports Viewer (in the Bean).

Parameters

  • Object source the datasource (the server name, foundset or dataset) to run the report on

  • String report the report file to export and preview (relative to the reports directory)

  • Object parameters the map of parameters to be used when previewing the report

  • String localeString the string which specifies the locale

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

Returns: void

Sample

var params = new Object();
params.SUBREPORT_DIR = "./Subreport_Tests/";
var report = myElement.showReport(customers_to_orders,"/Subreport_Tests/main_report_fs.jrxml",params);

Last updated