Welcome!

Jason Weathersby

Subscribe to Jason Weathersby: eMailAlertsEmail Alerts
Get Jason Weathersby via: homepageHomepage mobileMobile rssRSS facebookFacebook twitterTwitter linkedinLinkedIn


Related Topics: Eclipse Platform, Open Web Magazine

Eclipse Platform: Article

How to Develop an Application Using the Eclipse BIRT Design Engine API

Creating a customized report design application

Changing the Data Set Binding of a Report Item
You 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
After 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" );
design.close( );

Creating a Report Design Programmatically
You can 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)

More Stories By Jason Weathersby

Jason Weathersby is a member of the extended BIRT development team at Actuate Corporation and has backgrounds in both computer science and technical writing. He has many years experience in technical consulting, training, writing, and publishing about reporting, business intelligence tools, and database technologies.

More Stories By Tom Bondur

Tom Bondur is a member of the extended BIRT development team at Actuate Corporation and has backgrounds in both computer science and technical writing. He has many years experience in technical consulting, training, writing, and publishing about reporting, business intelligence tools, and database technologies.

More Stories By Jane Tatchell

Jane Tatchell is a content development manager in the Developer Communications group of Actuate Engineering.

Comments (0)

Share your thoughts on this story.

Add your comment
You must be signed in to add a comment. Sign-in | Register

In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.