Programming using the BIRT Reporting APIs : Programming the structure of a report design : Accessing a data source and data set with the API : How to bind a data set to a table
 
How to bind a data set to a table
The code sample in Listing 12‑26 shows how to check for a particular data set in a report design and changes the data set for a table. The code finds the table and data set by name. Alternatively, use slot handles to navigate the design structure. The variable, design, is a ReportDesignHandle object.
Listing 12‑26 Binding a data set to a report item
// Find the table by name.
TableHandle table = ( TableHandle ) design.findElement( "Report Data" );
 
// Find the data set by name.
DataSetHandle ds = design.findDataSet( "EuropeanCustomers" );
 
// Check for the existence of the table and the data set.
if ( ( table == null ) || ( ds == null ) )
{
System.err.println( "Incorrect report structure" );
return;
}
 
// Change the data set for the table.
try {
table.setDataSet( ds );
} catch ( Exception e )
{
System.err.println( "Could not set data set for table" );
}