The reports are stored locally in the filesystem accessible to the j2ee container running the JasperReportsIntegration j2ee application. This application will connect to the desired Oracle schema using connection information deployed in the J2EE container.
This j2ee application provides an url interface to calling the desired report against a desired data source.
So how can we pass parameters to our report, e.g. for producing a report for a specific customer or order number?
Let's consider my test report for that purpose (test.jrxml). The test report will list the user objects installed in the Oracle schema we connect to as well as produce some header information about the selected report locale. You can even pass three parameters to the report called parameter1, parameter2 and parameter3.
So, how can we pass the parameters to the report?
First of all we need to specifiy the parameters in the report itself. I have added the three parameters to the parameter list:
Currently all parameters (which we want to call from the JasperReportsIntegration kit) have to be specified as java.lang.String, no other data types are allowed. I might add that as a new feature in a later release. But for now only strings are allowed:
We assume that we have an APEX page with two page items, P1_FILTER_OBJECT_NAME and P1_FILTER_OBJECT_TYPE.
In order to pass these two parameters to the test report using the pl/sql interface XLIB_JASPERREPORTS, you would do the following:
declare l_additional_parameters varchar2(32767); begin -- set the url for the j2ee application -- better retrieve that from a configuration table xlib_jasperreports.set_report_url('http://localhost:8090/JasperReportsIntegration/report'); -- construct addional parameter list l_additional_parameters := 'parameter1=' || apex_util.url_encode(:p1_filter_object_name); l_additional_parameters := l_additional_parameters || '¶meter2=' || apex_util.url_encode(:p1_filter_object_type); -- call the report and pass parameters xlib_jasperreports.show_report (p_rep_name => 'test', p_rep_format => xlib_jasperreports.c_rep_format_pdf, p_data_source => 'default', p_additional_params => l_additional_parameters); -- stop rendering of the current APEX page apex_application.g_unrecoverable_error := true; end;
Why do we use apex_util.url_encode? This is required since we essentially pass the parameters via an url to the j2ee application.
When the report is executed, we get the following result (assuming P1_FILTER_OBJECT_NAME=APEX$ and P1_FILTER_OBJECT_TYPE=TRIGGER):
This will filter the result either bei object_name or object_type (in the example I filtered by the object type TRIGGER):
Hope that helps,