How to Develop an Application Using the Eclipse BIRT Design Engine API
Creating a customized report design application
Apr. 30, 2007 07:45 AM
Changing the Data Set Binding of a Report Item
can also use the report item's setDataSet( ) method to set or change
the data set used by a report item. If you change the data set used by
a report item, you must ensure that the contents of the report item
access only data bindings that are supplied by the new data set. If
necessary, you must change the references to data bindings in data
elements, text elements, and scripting methods. If the data bindings in
the old data set don't match the names or data types of the fields that
the new data set provides, you must correct the data bindings before
you generate a report from the modified report design. Use the
ReportItemHandle method, columnBindingsIterator( ) to iterate over the
column bindings that the report item uses. The items in the list are
ComputedColumnHandle types. This class provides methods to access the
name, expression, and data type of the column binding.
To access the data set column and expression that a data item uses,
call the methods, getResultSetColumn( ) and getResultSetExpression( ).
You can compare the data type and name with the result set columns that
the data set returns.
How To Bind a Data Set to a Table
The code sample in Listing 8
shows you how to check for a particular data set in a report design
then changes the data set for a table. The code finds the table and
data set by name. Alternatively use slot handles to navigate the report
design structure. The variable, design, is a ReportDesignHandle object.
Saving a Report Design Programmatically
making changes to an existing report design or creating a new report
design, you can choose to save the design for purposes of archiving or
future use. To overwrite an existing report design to which the
application has made changes, use the ReportDesignHandle save( )
method. To save a new report design or to keep the original report
design after making changes, use the ReportDesignHandlesaveAs( ) method.
Alternatively, if you don't need to save the changes to the report
design, use the ReportDesignHandleserialize( ) method. This method
returns an output stream. The report engine can generate a report by
opening a stream as an input stream.
If you don't need to make any further changes to the report design, use
the ReportDesignHandleclose( ) method to close the report design.
How To Save a Report Design
The code below saves the open report design. The variable, design, is a ReportDesignHandle object:
design.saveAs( "sample.rptdesign" );
Creating a Report Design Programmatically
build a report design and generate the report output in an application
without using BIRT Report Designer. You use the createDesign( ) method
on the session handle class, SessionHandle, to create a report design.
You use the other model classes to create its contents.
How To Create a New Report Design
The following code creates a report design:
SessionHandle session = DesignEngine.newSession( null );
ReportDesignHandle design = session.createDesign( );
ABOUT THE BOOK
This article is an excerpt from the
book Integrating and Extending BIRT by Jason Weathersby, Don French,
Tom Bondur, Jane Tatchell, and Iana Chatalbasheva and published by
Addison-Wesley. The book is the second volume in a two-book series
about business intelligence and reporting technology. The book
introduces programmers to BIRT architecture and the reporting
framework. It shows programmers how to build and deploy customized
reports using scripting and BIRT APIs. It also describes how to use key
extension points to create a customized report item, a rendering
extension for generating output other than HTML or PDF, and an Open
Data Access (ODA) driver for a new data source. (See Book)