Tutorial 10: Changing parameter values and definitions
This tutorial provides step-by-step instructions for authoring a web page that implements the parameterValue and parameterDefinition classes to set parameter values and control the visibility of parameters in a BIRT report displayed in BIRT Viewer. You perform the following tasks:
The file in this tutorial with a hidden parameter is Sales by Territory.rptdesign.
Task 1: Create a web page that processes parameters
In this task, you open or create a copy of JSAPITemplate.html and edit its contents to display a parameter and pass the value selected by the user to a BIRT report displayed in BIRT Viewer.
1 Using a code editor, open or create a JSAPITemplate.html file that contains the essential components for any web page that implements the JSAPI.
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
viewer.setReportName("/Applications/BIRT Sample App /Sales by Territory.rptdesign");
viewer.setParameterValues(paramvalues);
viewer.submit( );
}
6 Save the file as processparameters.htm.
7 In Internet Explorer, open processparameters.htm.
If you receive a security warning that Internet Explorer has restricted this page from running scripts or ActiveX controls that could access your computer, right-click on the message and select Allow Blocked Content.
8 On Please specify a territory, choose Japan, then choose Run Report. The Sales by Territory report for Japan appears, as shown in Figure 16‑7.
Figure 16‑7 Sales by Territory for Japan
Task 2: Display a hidden parameter using ParameterDefinition
In this task, you display a hidden parameter. Sales by Territory.rptdesign has two parameters, currentYear and Territory, but currentYear is a hidden parameter. To display currentYear, you use parameterDefinition to show the parameter normally.
1 Using a code editor, open processparameters.htm.
param.setReportName("/Applications/BIRT Sample App /Sales by Territory.rptdesign");
param.submit( );
param.downloadParameters(changeText);
}
function processParameters( ) {
param.downloadParameterValues(runReport);
}
function changeText( paramdef ) {
paramdef[0].setIsHidden(false);
param.renderContent( paramdef );
}
</script>
</div>
4 Save the file as displayparameters.htm.
5 In Internet Explorer, open displayparameters.htm.
If you receive a security warning that Internet Explorer has restricted this page from running scripts or ActiveX controls that could access your computer, right‑click on the message and select Allow Blocked Content.
6 The currentYear parameter for Sales by Terrritory.rptdesign appears, as shown in Figure 16‑8.
Figure 16‑8 currentYear parameter displayed on a web page