This section describes how to create an Ad Hoc report that prompts for input multiple languages. The tasks are:
|
•
|
Set the base name of the resource bundles in the JRXML Topic. |
|
•
|
Create resource bundles that contain translations for the prompts. |
|
•
|
Create an Ad Hoc report based on the JRXML Topic. |
|
•
|
Edit an input control to make prompts multi-lingual. |
|
•
|
Upload the resource bundles. |
|
•
|
Run the report and use the localized input control. |
The order of these tasks is important: Set the base name of the resource bundle in the JRXML Topic first, then create the Ad Hoc report. If you open the JRXML Topic after creating an Ad Hoc report, iReport removes grouping or sorting of data if there is any.
To set the base name of the resource bundles in the JRXML Topic:
|
1.
|
Start iReport. In iReport, click Window >JasperReports Server Repository. |
The Repository Navigator appears.
|
3.
|
Navigate to Ad Hoc Components > Topics and right-click the JRXML topic for this report: Parametrized Report. |
|
5.
|
Navigate to the Reports folder, right-click, and select Paste. The Parametrized Report topic appears in Reports. |
|
6.
|
To open the topic in the Designer tab, expand the Parametrized Report folder and double-click its main JRXML: ParametersJRXML_label. The Shipping Report appears in the Designer tab. |
|
7.
|
Click Window > Report Inspector. |
|
8.
|
In the Report Inspector, right-click the root node: ParamMany. |
In the main JRXML, ParamMany is the report name.
|
9.
|
From the context menu, choose Properties. |
In the figure “Selecting Properties of the ParamMany report”, you can see the ParamMany root node and Properties context menu.
The ParamMany Properties dialog appears.
|
10.
|
In the ParamMany Properties dialog, set the base name of the resource bundle to freight: |
|
a.
|
Scroll down to the Resource bundle property. |
|
b.
|
Click . |
In the figure “Setting the Base Name of the Resource Bundle”, you can see the properties of the ParamMany report.
|
11.
|
Click OK to close the ParamMany - Resource bundle dialog. |
|
12.
|
Click Close to close the ParamMany - Properties dialog. |
|
13.
|
Click File > Save to save the resource bundle name to the JRXML. |
|
14.
|
In the Repository Navigator, right-click ParametersJRXML_label. and choose Replace with Current Document. |
The modified JRXML with a base resource bundle name overwrites the Parametrized Report Topic in the repository.
To create resource bundles that contain translations for prompts::
|
1.
|
In a text editor, create a new file for English translations, and enter these name-value pairs in the file: |
BundleCountry = Country
BundleDate = Date
BundleOrder= Order
|
|
2.
|
Save the file as freight.properties. |

|
The file name of the default (English) resource bundle consists of the base name of the resource bundle and the properties extension.
|
|
3.
|
In a text editor, create a new file for French translations, and enter these name-value pairs in the file: |
BundleCountry = Pays
BundleDate = Datte
BundleOrder = Pour ID
|
|
4.
|
Save the file as freight_fr.properties. |

|
The file name of a localized resource bundle follows this Java naming convention:
<default_file_name>_<locale>.properties
|
•
|
<default_file_name> is the base name of the resource bundle |
|
•
|
<locale> is a Java-compliant locale identifier |
|
To create an Ad Hoc View based on the JRXML Topic:
|
1.
|
Log into the server as administrator, and choose Create > Ad Hoc View. |
|
2.
|
In the Data Chooser wizard, navigate to Ad Hoc Components > Topics, on the Topics tab, choose Parametrized Report. |
|
3.
|
Click Table. The Parametrized Report topic (a blank report) opens in the Ad Hoc Editor. |
|
4.
|
In the Measures list, double-click these fields: |
|
5.
|
In the Fields list, right-click Customer Id and select Add as Group. |
|
6.
|
Click Click to add a title, and enter Multi-lingual Input Prompts View. |
|
7.
|
Click , select Save Ad Hoc view As and Create Report. In the Save As dialog, select the Ad Hoc Reports folder, and enter: |
Data View Name: Multi-lingual Input Prompts View
Data View Description: A report that prompts for input in French and English.
Report Name: Multi-lingual Input Prompts View Report
|
8.
|
Browse to a location to save both the view and report. |
|
9.
|
Click Default Report Template. |
To edit an input control to make prompts multi-lingual:
|
1.
|
In the server, click View > Repository. |
|
2.
|
Locate the Multi-lingual Input Prompts View Report, right-click it, and choose Edit. |
The JasperReport wizard appears.
|
3.
|
Click Controls & Resources. The Controls & Resources page lists these input controls: |
|
4.
|
Click the Country input control. |
|
5.
|
On the Locate Input Control page, click Next to define an input control in the next step. |
|
6.
|
On the Create Input Control page, change the prompt text from Country to this expression: |
$R{BundleCountry}
In the figure “Entering a $R Expression in the Prompt Text Field” this expression is entered in the prompt text field.
|
8.
|
Accept the default settings on subsequent pages by clicking Next and Save: |
|
a.
|
On the Locate Query page, click Next. |
|
b.
|
On the Name the Query page, click Next. |
|
c.
|
On the Link a Data Source to the Query page, click Next. |
|
d.
|
On the Define the Query page, click Save. |
|
9.
|
On the Set Parameter Values page, click Submit. |
The Controls & Resources page now shows the $R{BundleCountry} expression instead of Country at the top of the list of input controls:
|
10.
|
Change the prompt text of the other input controls in a similar manner: |
|
a.
|
Repeat step 4 through step 6 to change the RequestDate and OrderID input controls to these expressions: |
RequestDate: $R{BundleDate}
OrderID: $R{BundleOrder}
|
b.
|
Accept the default settings on subsequent pages of the JasperReport wizard by clicking Next and Save. |
The Controls & Resources page now shows the $R expressions for all three input controls.
To upload the resource bundles::
|
1.
|
On the Controls & Resources page, click Add Resource. |
The Locate File Resource page appears.
|
2.
|
On the Locate File Resource page, select Upload a Local File. |
|
3.
|
Click Browse, locate the freight.properties file, select the file, and click Open. |
|
4.
|
On the Locate File Resource page, click Next. |
On the Add a Report Resource page, freight.properties appears as the Selected Resource, indicating that the server automatically detected it as a resource bundle.
|
5.
|
On the Add a Report Resource page, enter these properties: |
|
•
|
Name – freight.properties |
|
•
|
Resource ID – freight.properties |
|
•
|
Description – Default English resource bundle |
|
6.
|
Click Next. The list of resources on the Controls & Resources page now includes the resource bundle freight.properties. |
|
7.
|
On Controls & Resources, click Add Resource again, but this time, upload the French resource bundle: |
|
a.
|
On the Controls & Resources page, click Add Resource again. |
|
b.
|
Select Upload a Local File, click Browse, locate the freight_fr.properties file you created, select it, and click Open. |
|
c.
|
In Locate File Resource, click Next. The Add a Report Resource page appears: |
|
d.
|
Enter the following information: |
|
•
|
Name – freight_fr.properties |
|
•
|
Resource ID – freight_fr.properties |
|
•
|
Description – French resource bundle |
The Controls & Resources page shows the English and French resource bundles in the resources list.
To run the report and use the localized input control:
|
2.
|
On the Login page, click Show locale & time zone. |
|
3.
|
Select the en_US-English (United States) locale, and log into the server as an administrator. |
|
4.
|
Run the Multi-lingual Input Prompts Report. |
The report appears in the report viewer:
The input controls appear with English prompts.
|
7.
|
On the Login page, click Show locale & time zone. |
|
8.
|
Select the fr - French locale, and log in as administrator. |
|
9.
|
Run the report again and click Options. |
In the figure “Input Control Prompts in English and French”, you can see the input controls that with English and French prompts.