Book Excerpt
How to Develop an Application Using the Eclipse BIRT Design Engine API
Creating a customized report design application
Apr. 30, 2007 07:45 AM
Using an IReportRunnable Object To Access a Design Handle
You can also open a report design from an IReportRunnable object by
using the getDesignHandle( ) method. The ReportDesignHandle object
provides access to the design opened by the report engine. Changes to
the report design do not affect the IReportRunnable object. To generate
a report from the changed report design, you must reopen the design as
an IReportRunnable object.
How To Open a Report Design for Editing
The code sample in Listing 1
creates a DesignEngine object that it uses to create a SessionHandle
object. The code then uses the SessionHandle object to open a report
design.
Using a Report Item in a Report Design
A report
item is a visual element in the report design. Typically, a report
developer adds a report item to the design in the BIRT Report Designer
by dragging an item from the palette to the layout editor. Sometimes
you have to change the properties of certain report items in the design
before running the report. An application uses methods on the
ReportDesignHandle class to access a report item either by name or from
a list of items in a slot in a container report item.
A slot is a logical component of a report item. For example, a table
element has five slots: Header, Detail, Footer, Groups, and Columns. In
turn, each of these slots can have further slots. Each slot has zero or
more members of the appropriate report item type. For example, the
Header, Detail, and Footer slots all contain elements of the RowHandle
type. RowHandle has a Cell slot that contains all the cells in the row.
For a visual representation of the slots in an individual report item,
see the Outline view in BIRT Report Designer.
Accessing a Report Item by Name
To make a report
item accessible by name, the item must have a name. A report developer
can set the name in BIRT Report Designer or programmatically by using
the item's setName( ) method. To find a report item by name, use the
findElement( ) method. This method returns a DesignElementHandle
object. All report items derive from this class.
Accessing a Report Item by Iterating through a Slot
To access a report item through the report design's structure, the
application first gets the slot handle of the report body by calling
the getBody( ) method. This slot handle holds the top-level report
items in the report design. For example, consider a simple report
structure that has three top-level items: a grid containing header
information, a table containing data, and a label that displays a
report footer. Figure 1 shows its outline view in BIRT Report Designer.
To access the top-level items in this report design, you
iterate over the contents of the body slot handle. These contents all
derive from DesignElementHandle. To access the iterator for a slot
handle, call SlotHandle.iterator. Each call to Iterator.getNext( )
returns a report item. Alternatively, to access a report item at a
known slot index, call SlotHandle.get(). The slot index number is
zero-based. The ReportDesignHandle class also provides finder methods,
which can access an item or other report element by name.
About Jason WeathersbyJason 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.
About Tom BondurTom 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.
About Jane TatchellJane Tatchell is a content development manager in the Developer Communications group of Actuate Engineering.