Introduction
Eclipse's Business Intelligence and Reporting Tools (BIRT) project is an open source project based on the popular Eclipse IDE and is used to build and deploy reports in a Java/J2EE environment. Some of the key downloads available with the project include:
- BIRT Designer - Used to construct reports.
- Web Viewer - An example J2EE application used to deploy reports, containing a JSP tag library to ease the integration with existing web applications.
- BIRT Charting package - Supports building sophisticated actionable charts.
The BIRT project had its first major release in the summer of 2005 and has garnered over a million downloads since its inception. To learn more about the BIRT project see http://www.eclipse.org/birt, which includes an introduction, tutorials, downloads, and examples of using BIRT.
We will begin by first describing the BIRT designer, which is used to build report designs, and conclude by discussing the example BIRT Viewer, which is used to deploy the designs and generate the completed reports.
BIRT 2.2 Collage
BIRT Designer
At the center of BIRT is the report designer, which is a set of Eclipse plug-ins that make up the designer perspective providing drag-and-drop capabilities to quickly design reports. The reports designs are created and stored in an XML format.
Figure 1 - Eclipse BIRT Designer
This Eclipse perspective contains many Eclipse Views that provide the functionality for creating a report. These views are delineated below.
Report Editor
The Report Editor is used to construct the report and acts as a canvas for positioning and formatting report elements. Within this View, there are tabs for Layout, Master Page, Script, XML Source, and Preview.
- The Layout tab is used for the visual layout of the report and supports drag-and-drop functionality.
- The Master Page is used for setting the header, footer, and background image configurations for the entire report. For example, this page is often the location of the corporate header.
- The Script tab allows access to the JavaScript editor. BIRT supports an event model that allows handlers to be written in Java or JavaScript. These handlers are called throughout the generation and rendering process and allow modification of report properties, like changing font colors, the data value, and calling external code.
- The XML Source tab displays the XML source code for the report design. It is possible to edit the XML within this tab, although it is generally best to use the Layout View.
- Preview allows the report developer to quickly render a working report to HTML. Note that you can also preview reports in other supported formats using the toolbar.
Figure 2 - BIRT Preview
Data Explorer
Before constructing a report, setting up data sources is usually required. To facilitate this task, BIRT provides the Data Explorer View.
Figure 3 - Data Explorer View
This Eclipse view allows the designer to add data sources and data sets to the report design. Essentially, a data source is just the connection. The data set can be thought of as an executed query and the specific columns it returns.
BIRT provides drivers for JDBC, XML, flat file, and scripted data sources. With the release of BIRT 2.2, BIRT also provides a Web Service data source and an improved flat file driver that now supports CSV, TSV, SSV, and PSV file formats.
BIRT also provides a special data set called a Joint Data Set that allows combining existing data sets using inner and outer joins. This feature is very useful when combining data sets from different data sources. In addition, BIRT data sources now support the ability to link or import connection profiles that are stored locally to allow sharing of connection credentials across reports.
The Data Explorer View is also used when adding report parameters and data cubes. Report parameters are parameters that are exposed to the end user of the report and are often used to personalize the report for a given user. Report parameters for example, can be tied to data set parameters to modify a query, used in a BIRT JavaScript expression to change the style and visibility of a report element, or used within a script event to personalize the content based on the selected output format.
Report parameters can be static or dynamic. Static parameters are parameters that allow the user to select from a predefined set of values or to enter a desired value, for example, in a text box. Dynamic parameters are parameters that can be data bound to an existing BIRT data set. For example, a user may select a customer from a list of customers provided by a data set.
In addition, BIRT supports cascading parameters that allow multiple list/combo boxes to be displayed with each subsequent selection list being modified by previously selected values. For example, a cascaded parameter could present a customer list in the first list box and the orders for the given customer in a second list box.
Figure 4 - Cascaded Parameter
With BIRT 2.2, dynamic parameters now support using Java Script expressions for the display text and value of the parameter. This improvement allows the parameter list to be displayed to the end user in a much more logical manner. For example, when developing an order detail report, you may wish to present a dynamic parameter list of all orders. The expression would allow you to also add in the customer name for each order. Figure 5 shows a dynamic parameter list.
Figure 5 - Dynamic Parameter Expression
The Data Explorer View also allows the creation of data cubes. This is a new feature for BIRT 2.2 and is used in conjunction with the new crosstab report element. BIRT data cubes are multi-dimensional cubes, based on one or more BIRT datasets, constructed using the new Cross Tab Cube Builder. See Palette View for more details.
Figure 6 - Cross Tab Cube Builder
In addition to the above features, BIRT now provides two new project types that allow Java developers to create additional data sources. These data sources are based on the Open Data Access (ODA) framework provided by the Eclipse Data Tools Platform (DTP) project. The ODA Designer Plug-in Project is used when constructing the GUI, which is called when a report developer uses your driver. The ODA Runtime Driver Plug-in Project is used when developing the run-time portion of your driver. This plug-in is usually deployed to a run-time environment and is responsible for making the calls to the data source and retrieving the results.
Figure 7 - BIRT Projects
Palette
The BIRT Palette View is used to add report items to the report canvas. The Palette View contains the report elements that are used to present the data collected in the Data Explorer View. To use a report, simply drag it from the Palette View to the Report Editor. All BIRT report elements support properties that can be configured in the Property Editor View and are described by the BIRT Report Object Model (ROM).
Figure 8 - Palette View
The palette supports the following report items.
- Label elements are used for displaying static text. As with most report elements, the text can be externalized for localization and supports such properties as hyperlinking, font sizing, and highlighting.
- Text elements are similar to Labels, with the additional benefit of being able to display multi-line, highly formatted HTML. Values from existing data sets, parameters, JavaScript functions, and BIRT specialized script functions can also be injected into the formatted HTML using the BIRT Expression Builder. The element can also be used to create scripts that are executed on the client side by using the tag.
- Dynamic text elements are most often used to display CLOB data type values. These values can also be combined with additional data using the BIRT Expression Builder.
- Data elements are the essential element for displaying values from data sources. Using the Expression Builder, data values can be altered and manipulated. For example, if a data set contains a column for first name and another for last name, using the expression builder you can concatenate the values into one data element.
dataSetRow["contactLastName"] + ", " + dataSetRow["contactFirstName"]
- Image elements are used to include pictures in the report output. BIRT supports retrieving images from a URI, embedding the image in the design, dynamic images (BLOB) from a data source, and image files in a resource folder.
- Grid elements act as containers for other report elements and are used to position elements in a logical manner. Grid elements are configured in tabular format. For example, if your report is displaying product sales and you want a chart representation to the right of your table data, you would add a grid element with one row and two columns.
- List elements also act as containers for other elements. Lists differ from other container elements in that they iterate over data sets that are bound to the list. The default list element has a header, footer and detail section. When the list is rendered, the header and footer are usually displayed once, while the detail section is displayed for every row of the data set that is bound to the list. Within the detail section you may have a text element or another container element such as a grid, table or another list.
- Table elements are similar to list in that they are container elements that iterate over bound data sets, but are represented in tabular format. The table element layout is similar to an HTML table. Table elements have header, footer and detail sections as well as columns.
- Aggregation elements are new for BIRT 2.2 and provide functionality to add aggregate elements to the report using the new aggregation builder. The Aggregation Builder supplies over twenty-five different functions such as SUM, MIN, MAX, and AVERAGE.
Figure 9 - Aggregation element
- The chart element allows charts to be inserted into the report design. When a chart element is placed in the Report Editor, the Chart Builder Wizard automatically displays. This wizard is used for designing the chart and offers three design tabs (Select Chart Type, Select Data, and Format Chart). Thirteen primary chart types and many combinations of sub-types are available with BIRT 2.2. The Chart Builder provides drag-and-drop functionality, live chart preview, data filtering, and parameterization. Chart elements can be presented in PNG, JGP, BMP, and SVG output, which support drilling through and highlighting, toggling visibility, and client side script.
Figure 10 - Chart Wizard
- The Cross Tab element is also new for BIRT 2.2 and can be used to display data contained within a BIRT data cube. In previous versions of BIRT, the number of columns in a table element had to be known at design-time, whereas with the cross tab element, the number of columns and rows can be dynamic. This element also supports hierarchal aggregation and display of data, allowing cube dimensions to be placed on rows and columns, and measuring data to be displayed at appropriate intersections.
Figure 11 - BIRT Cross Tab element
Library Explorer
The Library Explorer View allows drag-and-drop functionality from existing report libraries into the current report. Libraries in BIRT are effectively report XML snippets that can be used by other reports. These libraries are referenced from reports that use them, meaning that changes in the library are automatically reflected in all reports that use the library. A good example is using a report library to store the company logo. If the company logo changes, only the library needs updating, not the reports that references it. Libraries are referenced relative to the resource folder which is configurable in the designer for design-time and in the web.xml of the Web Viewer for run-time.
Figure 12 - Library Explorer
Property Editor
The Property Editor View is used to set properties for report elements that have been added to the report. The items displayed will be determined by what report element is selected in the Report Editor. The Properties window presents common settings, such as style, width, and font information. Additionally, most report elements support the visibility property that allows hiding content dynamically. To the right of the Properties tab, this view features Sorting, Groups, Map, Highlights, and Filters tabs.
While most of these functions are self explanatory, the Map tab allow dynamic conditions to be built (using the Expression Builder) that dynamically change the display value of a report element. For example, if your month row value is "1", you may want to display "January".
The Highlights tab uses conditions to apply different style formats dynamically, such as showing low sales numbers in red. Most of these functions allow multiple conditions or keys to be placed on an item. One condition may change the color of the font, while another condition may change the font size. One sort key can list the results alphabetically, while another sort key puts "Jones" at the top of the list.
Figure 13 - Property Editor
In addition, with BIRT 2.2, when applying highlights, the report developer can now specify a style instead of setting the style properties manually.
Figure 14 - Style Highlighting
Outline
The Outline View presents a graphical hierarchy of the report design and illustrates the report element to container relationship. Report elements can be directly selected within the outline view and is very helpful when you have complex report designs. Additionally with BIRT 2.2, this view can be used to import or link external styles and to view report elements that have implemented script event handlers.
Figure 15 - Outline View
Importing a style sheet copies the values of the style into the report XML. Using an external style sheet allows you to link to a style sheet located in the BIRT resource folder.
Miscellaneous
BIRT 2.2 also provides two new views for examples. One view displays example reports and the other displays example charts and provides Java code to produce the chart. This view is used when using the chart engine in a Java application.
Figure 16 - Example Views
Eclipse BIRT Web Viewer
Once report development is complete, the reports can be deployed using the BIRT example Web Viewer. The viewer has been improved for BIRT 2.2 and is an AJAX based J2EE application that illustrates using the BIRT engine to generate and render report content.
Web Viewer Overview
The Web Viewer can be used to generate and render reports, and also supports more interactive features such as table of contents, exporting report content to several formats, client and server-side printing, as well as report pagination. These features are enabled using the Viewer navigation and tool bars. An example of using the Viewer is illustrated below.
Figure 17 - Example Web Viewer
Toolbar
The Viewer toolbar has icons for displaying the table of contents, re-running the report, exporting data, exporting the report to another format, and client and server-side printing. A table of contents is generated automatically based on the report design. The TOC can be customized by modifying the group sections of the report. To access the TOC from the example Viewer, select the icon.
Figure 18 - Example Table of Contents
The toolbar also supplies an icon to re-run the existing report. This can be useful when the user wants to modify the set of parameters that were used to generate the report. To access the feature, select the icon.
Figure 19 - Example report parameter dialog containing cascaded parameter
New for 2.2 is an improved data export dialog. This dialog is enabled by selecting the icon.
Figure 20 - Example Export Data Dialog
The available result sets are displayed in a dropdown list that contains all data bound controls in the report. These result sets are not BIRT data sets, but contain the bound columns from the data container, which are usually retrieved from a data set. The available columns are displayed in the left list box and the dialog has controls to select these columns for export. The data export separator has also been improved to support additional delimiters, such as tabs, semicolons, colons, vertical lines, and tabs. Additionally, the data can be exported using a user-specified encoding.
The Viewer also supports exporting the report to additional formats. Exporting is done using the export report dialog, which can be accessed by selecting the icon.
Figure 21 - Example Export Report Dialog
This dialog allows the report consumer to export the report to Word, PowerPoint, PDF, PostScript, and XLS formats. Additionally, the user can select all pages or a specific page range to export.
Client-side printing in BIRT is achieved within the example viewer by converting the report to PDF format when the user selects the icon. The user can print or save the report using standard PDF functionality.
Figure 22 - Client Print Example
The 2.2 example Viewer also adds the capability to do server-side printing. This feature can be disabled with the following setting located in the web.xml.
<context-param>
<param-name>BIRT_VIEWER_PRINT_SERVERSIDE</param-name>
<param-value>OFF</param-value>
</context-param>
Server-side printing can be accessed by selecting the icon.
Figure 23 - Example Server Side Print Dialog
This dialog will list the available server printers as well as various settings to affect how the report is printed.
Viewer Navigation Bar
The Viewer navigation bar is used when displaying a multi-page report. Pagination is determined by the page-break properties of report elements and groups. These properties can be as simple as page-break before and after or by using the page-break interval, which specifies how many rows for a container element to process before inserting a page break into the emitted HTML. When using the Viewer with the Frameset Servlet mapping, the default behavior for the viewer is to load the first page and to enable the navigation bar controls. The navigation bar contains controls to navigate forward and backward as well as the ability to enter a page to load directly.
Web Viewer Deployment Wizard
Using portions of the Web Tools Platform Project (WTP), BIRT 2.2 now supplies a Web Project. This project type will automatically deploy the example Viewer to your selected application server. In addition, the new BIRT tag library will also be deployed. To use this project type, select a new project, and, under the Business Intelligence and Reporting Tools category, choose Web Project.
Figure 24 - Web Project
Web Viewer Tag Library
The Web Viewer now contains a tag library that can be used to customize the behavior of the Viewer. This tag library can be deployed by either deploying the viewer as normal or by using the BIRT Web Deployment project wizard. In addition, if you desire to have BIRT deployed in one context and include the tag library in a separate context, this can be done by copying the birt.tld file to your WEB-INF\tlds directory and copying coreapi.jar, modelapi,jar, viewerservlets.jar and com.ibm.icu_3.6.1v20070417.jar from the Viewer libs directory to the new context/web-inf/lib directory. Add the following reference to your web.xml:
<jsp-config>
<taglib>
<taglib-uri>/birt.tld</taglib-uri>
<taglib-location>/WEB-INF/tlds/birt.tld<
/taglib-location>
</taglib>
</jsp-config>
Using this approach reports are referenced in relation to the BIRT Viewer, not the new context.
The Viewer tag library contains five tags: param, paramDef, parameterPage, report and viewer. Each tag has multiple attributes that control the behavior of the Viewer.
Figure 25 - BIRT Tag Library
Conclusion
This article touches on some of the new features for BIRT 2.2. To learn more, visit the BIRT website and the BIRT newsgroup.