Expand a template at runtime
Genero Report Writer provides the option to add data sources and the associated mapping to a template at runtime. Therefore, you can provide end users with generic reports that can be expanded at runtime.
This method uses a report template (.4rt) and design-time APIs to provide the details about the schema, the schema root, the relationships, and the field mappings in order to output the report, bypassing any need for a report design document. While more complex to set up, the advantage is that changes to your template are reflected with each new run of the report.
- The user is prompted for information regarding the template to use and the values to use
(variables and placeholders). While all the same options as sophisticated as the template
assistant in the report designer are available, typically the following things will be
simplified:
- You can't choose multiple different templates. If choices are given, they are limited to styles that match the data source (e.g. don't offer a grouped list when the data source doesn't have groups).
- You won't be prompted for difficult placeholders, for example those that require the construction of formulas (e.g. Total expressions), and will only be prompted for simple values (e.g. the Title of the report).
- You must choose fields from a single list of fields. Therefore, templates that offer more than one field lists will not be used.
Note: Building the dialog in a generic way to avoid hard coding placeholder and field lists requires software that can introspect schema files and .4rt files. A library is provided for that. - The information entered by the user is used to expand the template and generate a
.4rp file.Note: Expanding the template can be done in one of two ways:
- By calling an existing library function from the code.
- By invoking the GenerateReport executable provided with GRE.
- The data source is run using the generated .4rp file. Note: The data source is run with the .4rp via the normal runtime API functions.
View an example of expanding a report at runtime
- Open the OrderReportJava demo from the Welcome Page.
- In the Projects view, right-click on the OrderReportJava node and select Execute. The Order Report window opens.
- From the Report drop down list, select Generic List and click Preview. A window opens with a list of all available and selected fields.
- Modify the lists by dragging the fields to and from the Available fields and Selected Fields lists.
- Click Ok.
- To preview the changes that you have made, click Preview.
To assist you in writing a dynamic generic report, examine the
GenericReportDialog.java file to see the use of the classes within
the code, for example the SchemaUtil.getFields
and
PXMLUtil.generateDesignFromTemplate
.
You can view the complete list of available classes and methods in the Genero Studio Help, which can be accessed by going to
.