Displaying BIRT designs in a web view
Displaying the visualizations and layout of a BIRT design in HTML requires JavaScript and the Actuate JSAPI. Using JSAPI enables you to embed a BIRT design or BIRT document into an HTML web page. BIRT Gazetteer uses an iOS UIWebView class to embed a single HTML file, jsapi.html. This HTML file is included in the /jsapi folder of the Xcode project and contains the Actuate JSAPI necessary to display a BIRT design or document file. The JavaScript in jsapi.html enables you to select the BIRT design file to display and to pass parameter and bookmark values to the report before it is displayed.
Objective-C calls the init() JavaScript function in the HTML file and passes the prepared string, as shown in the following code:
[webView stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat:@"%@(%@);",@"init",jsonStr] ];
The JavaScript API then assigns all of the required values to download and display BIRT content and submits the request to the iHub server for display in the HTML DIV entity with the id name container. The following JavaScript code summarizes this request:
function initViewer( )
{
try
{
var viewer = new actuate.Viewer( "container");
viewer.setReportDesign( report );
viewer.setWidth(data.width);
viewer.setHeight(data.height);
var options = new actuate.viewer.UIOptions( );
options.enableToolBar(false);
var parameterValues=[];
if(data.continent != null) {
var param=new actuate.viewer.impl.ParameterValue();
param.setName("continent");
param.setValue(data.continent);
parameterValues.push(param);
}
...
if (parameterValues.length > 0 ) {
viewer.setParameterValues(parameterValues);
}
if (data.bookmark != null) {
viewer.setReportletBookmark(data.bookmark);
}
viewer.setUIOptions( options );
viewer.submit();
}
}
...
</script>
<body onload="">
<div id ="container">
</div>
</body>
See the source code for the complete example.