Retrieving report content as data
To retrieve report content as data, use the actuate.DataService class from the Actuate JavaScript API. The DataService is packaged with the actuate.Viewer class. Load the actuate.DataService class with actuate.load( ), as shown in the following code:
Load the viewer component to use data services on the page. Call the functions in the actuate.DataService class to prepare report data, then call downloadResultSet( ) from the DataService class to obtain the report data.
Using a data service component
The actuate.DataService class is a container for Actuate report data. Create an instance of the class with JavaScript, as shown in the following code:
var dataservice = new actuate.DataService( );
Without parameters, the actuate.DataService class uses the Actuate web application service called in actuate.intialize.
To gather data from a report, define a request and send the request to the Actuate web application service for the data. The object defines a request. To construct the Request object, use the constructor, as shown below:
var request = new, start, end);
*bookmark is a bookmark that identifies an Actuate report element. The object uses the bookmark to identify the report element from which to request information. If bookmark is null, the object uses the first bookmark in the report.
*start is the numerical index of the first row to request. The smallest valid value is 1.
*end is the numerical index of the last row to request. A value of 0 indicates all available rows.
To download the data, use dataservice.downloadResultSet( ), as shown in the following code:
dataservice.downloadResultSet(filedatasource, request, displayData, processError);
*filedatasource is the path and name of a report file in the repository. For example, "/public/customerlist.rptdesign" indicates the Customer List report design in the /public directory. The dataservice.downloadResultSet( ) function uses the Actuate web application service set with actuate.Initialize( ) by default.
*request is an object that contains the details that are sent to the server in order to obtain specific report data.
*displayData is a callback function to perform an action with the downloaded data. This callback function takes an object as an input parameter.
*processError is a callback function to use when an exception occurs. This callback function takes an actuate.Exception object as an input parameter.
JSAPI DataService cannot download ResultSets from BIRT report elements with an automatically generated bookmark. When designing a report, report developers can explicitly specify bookmarks for report elements. If a bookmark is not specified, the report generates a generic bookmark name automatically when it executes. The JSAPI DataService class cannot retrieve a result set from these generic bookmarks. To use the JSAPI DataService on a bookmark, the report developer must specify a name value for the bookmark.
To provide a quick alert displaying the column headers for the retrieved data set, use code similar to the following:
alert("Column Headers: " + myResultSet.getColumnNames());
where myResultSet is the ResultSet object retrieved by downloadResultSet.
Using a result set component
The class is the container for the report data obtained with actuate.dataservice.downloadResultSet( ). Because a ResultSet object is not a display element, an application can process or display the data in an arbitrary fashion.
The ResultSet class organizes report data into columns and rows, and maintains an internal address for the current row. To increment through the rows, use the ResultSet’s next( ) function as shown in the following code:
function displayData(rs)
while ( ))
In this example, rs is the ResultSet object passed to the displayData callback function. To read the contents of the ResultSet object, a while loop increments through the rows of data with ).
Because a web page that loads a DataService object also loads initiates the viewer, the target for displaying a result set must be a separate page or application.