The data controller object enables you to interact with Business Intelligence data sources. The primary interaction is as follows:
-
In a suitable part of the page logic (such as when the page is loaded or when a button is pressed), create a Business Intelligence data controller and execute a query.
When you create a data controller, you specify one or two callback functions to be run when data is available; finalCallback is required, but pendingCallback is optional.
-
When pending results are available, Business Intelligence calls the method specified by pendingCallback, if specified.
This method, which you write, uses the results that are available in the data controller object. The method typically draws page contents.
-
When the query has completed, Business Intelligence calls the method specified by finalCallback.
This method, which you write, uses the results that are available in the data controller object. The method typically draws page contents.
Any method that executes a query uses the system described here; see the subsections for details and examples. Other methods return data synchronously.
Using Data Returned by the Data Controller
The page must also implement the callback function or functions referred to in the previous step. These callbacks should update the page as needed, using data obtained from the data controller object.
In each case, the data controller object is passed to the function as the argument.
The following shows a partial example:
function drawChart(dataController) {
var resultSet = dataController.getCurrentData();
...
var chartDataPoint;
var chartLabel;
var chartData = [];
for (var i = 1; i <= resultSet.getRowCount(); ++i) {
for (var j = 1; j <= resultSet.getColumnCount(); ++j) {
chartDataPoint = resultSet.getOrdinalValue(i,j);
chartLabel = resultSet.getOrdinalLabel(2,i);
chartData[chartData.length] = { "country":chartLabel[0],"revenue":chartDataPoint};
}
}
...
}
The getCurrentData() method of the data controller returns another object, the result set object. That object provides methods for examining the results of the query. The example here shows some of them.