Example 3: XML file with dynamic parameters

When you design a report from the tables imported through OOJDBC, and the tables have the same input parameters, but you don't want to input the same parameters again, JReport provides a way to allow you to bind parameters in a catalog, so they can share the same parameter value.

This example demonstrates how to import tables with dynamic parameters from the ODF file generated by the Model Wizard.

Importing the XML file using the Model Wizard

To import an XML file with the Model Wizard, take the following steps:

  1. Run ModelWizard.bat in <install_root>\bin. The Object Source Wizard will then appear.
  2. Add two tables as shown in Example 1. The first table named employee1 has one String type column, and the second table named employee2 has one Int type column. They have the same input parameter for param0. The default value is h:\xml\employee.xml. Make sure to check the option Is Dynamic.
  3. In the Object Source Wizard, click File > Save. You will then be prompted to save the ODF file. You should save it to <install_root>\lib or the directory where the catalog will be. Here we save it as xmlparam.odf.

Notes:

Importing the ODF file into a catalog

To import the generated ODF file into a JReport catalog, take the following steps:

  1. Start JReport Designer.
  2. Click File > Catalog Management > New Catalog.
  3. In the Input New Catalog Name dialog, specify the catalog name, the data source name and the path. The catalog should be located in the directory where you saved the ODF file. For example, if you saved the ODF file in C:\odf, the new catalog should be created also in C:\odf.
  4. In the Catalog Browser, create a parameter that is of String data type and is named path. This parameter will be bound to the parameters in the tables that were imported through OOJDBC.

  5. Create a new connection in the Get JDBC Connection Information dialog as follows:

  6. The Add Table dialog appears prompting you to add the listed tables. Select the table employee1 and click the Add button. The Dynamic Parameter used in oojdbc tables dialog will then be displayed. Uncheck the checkbox in the New column and select the parameter path from the drop-down list to bind param0 to the parameter path.

  7. Repeat the above step to add the employee2 table and bind its parameter param0 to the parameter path. Now the parameters in the two tables will share the same parameter path.
  8. Click the New Page Report button on the Standard toolbar to develop a report on the newly inserted tables.
  9. When viewing the report, the Enter Parameter Values dialog will be displayed, asking you to input the parameter. You will only need to input the path of imported XML file once since the parameter is shared with the parameters in the two tables.
Modifying the dynamic parameters

You can modify the links between the parameters in OOJDBC and parameters in the JReport catalog. To do this:

  1. Launch the Catalog Browser in JReport Designer.
  2. Select the table with the dynamic parameters that are to be modified. Right-click on the specified table, and then select Parameters from the shortcut menu.
  3. Highlight the parameter in the catalog, and then select the parameter from the drop-down list to bind it to the parameter in OOJDBC.