Creating the report design file

EGL works with the JasperReports open-source, Java-based reporting library to create reports. Unless you import a working design file (extension jasper), you will need to create or modify an XML source for the design file. For more detailed information than you will find in this topic, see the following Web site:

http://jasperreports.sourceforge.net

You can use a file with the .xml extension for your source, though this could slow your compilation. JasperReports recommends the .jrxml extension.

To add a design document to a package, follow these steps:
  1. Create a design document in one of the following ways:
    • Use a third-party JasperReports design tool (like JasperAssistant or iReport). Make sure the file you create has a .jrxml extension.
    • Use a text editor to write JasperReports XML source information into a new text file and save the file as a .jrxml file.
  2. Place the XML design document in the same EGL package as your report driver file and optional EGL report handler.
  3. Customize the XML source file to use one of the following data sources:.
    • When you have a fairly simple, straightforward database query, create a report of type DataSource.databaseConnection. Include your SQL query in the XML design file source. The EGL report driver passes your connection information to JasperReports.
    • When you need to perform complex database operations, or need to build your SQL statement dynamically, create a report of type DataSource.sqlStatement. The EGL report driver includes your SQL query and passes the result set to JasperReports.
    • When your data comes from somewhere other than a database, create a report of type DataSource.reportData. The EGL report driver passes complete report data to JasperReports; no connection information is necessary.

The following sections offer specifics for the different types of XML source files. This information covers very simple cases; for more complex examples see either the JasperReports Web site mentioned earlier or the documentation for your design tool (if you decide to use one).

EGL source files of type DataSource.databaseConnection

Include connection information in your EGL source file and include your SQL query in the XML design file source. Here is the syntax for a very simple case:
<queryString><![CDATA[SELECT * FROM Table_Name]]></queryString> 
Table_Name
Name of a table from your database
Define the specific fields (tied to columns in the SQL result set) you want to use:
<field name="Field_Name" class="java.lang.class_type"></field>
Field_Name
A column name in the result set from the query in your design file. The field names must conform to Java™ variable name conventions. You can alias column names within your SQL statement to handle duplicate names, illegal characters (such as "."), or other conflicts.
Class_Type
A java.lang class such as Integer or String, identifying the type of data to which Field_Name refers
Place the fields on the report with a TextFieldExpression tag:
<textFieldExpression class="java.lang.class_type"><![CDATA[$F{Field_Name}]]></textFieldExpression>

EGL source files of type DataSource.sqlStatement

Place your SQL statement in the EGL report driver file. You can either specify your connection explicitly in your report driver or use the default connection in your build descriptor. In the XML design file, define the specific fields you want to print on the report. The field names refer to column names in your SQL statement's result set:
<field name="Field_Name" class="java.lang.class_type"></field>
Field_Name
A column name in the result set that was created by the query in your EGL report driver. The field names must conform to Java variable name conventions. You can alias the column names within your SQL statement if necessary.
Class_Type
A java.lang class such as Integer or String, identifying the type of data to which Field_Name refers
Place the fields on the report with a TextFieldExpression tag:
<textFieldExpression class="java.lang.class_type"><![CDATA[$F{Field_Name}]]></textFieldExpression>

EGL source files of type DataSource.reportData

Here you do not use a database, so you do not need a connection or SQL statement, either in your XML source or in the EGL report driver. Instead define the specific fields you want to use from the records that you create in the EGL report driver:
<field name="Field_Name" class="java.lang.class_type"></field>
Field_Name
The name of a field exactly as you specified it in your EGL source file
Class_Type
A java.lang class such as Integer or String, identifying the type of data to which Field_Name refers
Place the fields on the report with a TextFieldExpression tag:
<textFieldExpression class="java.lang.class_type"><![CDATA[$F{Field_Name}]]></textFieldExpression>

Compiling the XML design file source

EGL automatically compiles any .jrxml file it finds in the package directory in the EGL source folder, providing these conditions are true:
  • The .jrxml file has changed
  • The .jrxml file is free of errors
  • The javac compiler is on your execution path

EGL places the compiled .jasper file in the JavaSource\package_name directory that is parallel to EGLSource\package_name. When you successfully generate your EGL report driver, the product places a linked copy of the .jasper file in the parallel bin\package_name directory. You can force the .jasper file creation and copy by selecting Project > Build All or Project > Clean.

If you are creating an XML design document and a report handler simultaneously, see EGL report creation process overview for guidelines. For an example that shows how an XML design document gets a report data record from the report handler, see Creating an EGL report handler.

Related conceptsEGL reports overview
EGL report creation process overview

Related tasks
Creating an EGL report handler
Writing code to drive a report

Related reference
EGL library ReportLib
Data types in XML design documents

Feedback
(C) Copyright IBM Corporation 2000, 2005. All Rights Reserved.