Additional JasperReport handler functions
When you add the JasperReport stereotype to a Handler part, you automatically make a number of implicit EGL functions available. Additionally, the JasperReports design file can invoke the getDataSource() internal Java™ method.
- Parameters ($P{parameter_name}) keep the same value throughout the process. You can use them to pass a value from the report engine to the JasperReport handler (but not the other way around).
- Variables ($V{variable_name} can be read or set by the JasperReport handler. The design file can also change their values.
- Fields ($F{field_name}) map data from the data source to the printed report. The JasperReport handler can read values from fields but cannot change those values.
You can call any of the implicit functions in the following sections from within the JasperReport handler. Invoke getDataSource(), which is an internal EGL Java™ method, from the XML design file source.
Function for getting report parameters
| Function | Description |
|---|---|
| getReportParameter (parameter STRING in) | Returns the value of the specified parameter from the report that is being filled. The returned value is of type ANY. |
Functions for setting and getting report variables
You can use the following functions at run time to access variables that the report uses.
| Function | Description |
|---|---|
| getReportVariableValue (variable STRING in) | Returns the value of the specified variable from the report that is being filled. The returned value is of type ANY. |
| setReportVariableValue (variable STRING in, value Any in) | Assigns the value to the specified variable. |
Function for getting field values
You can use the following function to access current fields in the report.
| Function | Description |
|---|---|
| getFieldValue (fieldName STRING in) | Returns the value of the specified field value for the row currently being processed. The returned value is of type ANY. |
Functions for storing or retrieving data for subreports
A subreport is a report that you call from within another report. To pass report data to a subreport, the JasperReport handler first saves the information using addReportData(). The JasperReports engine can retrieve this data by means of getDataSource(); see "Java™ methods available to the report design file" in this topic. To retrieve previously saved data within the JasperReport handler, use the equivalent getReportData() function.
| Function | Purpose |
|---|---|
| addReportData (rd ReportData in, dataID String in) | Associates data (as stored in a ReportData variable) with the name dataID. |
| getReportData (dataID String in) | Retrieves data that you previously stored under dataID using addReportData(). getReportData() returns a value of type ReportData. |
Java™ methods available to the report design file
To access data that you pass to a subreport, call the getDataSource() function from your XML report design file.
| Function | Purpose |
|---|---|
| getDataSource (dataID STRING in) | Within a report design file, retrieves data that you previously stored under dataID when you invoked addReportData() in the JasperReport handler. getDataSource() returns the data in an internal format. You must cast the return value as a JRDataSource for the subreport to be able to use that data. |
For examples showing how to use the functions described in this topic, refer to the EGL Programmer's Guide.