The actuate.Viewer class retrieves and displays Actuate BIRT report contents in an HTML container. The actuate.Viewer class displays the report by page. The goto functions of this class change the current position and page displayed in the viewer.
Constructor
Syntax
actuate.Viewer(object viewContainer)
actuate.Viewer(string viewContainerId)
Constructs a new viewer object. The container is an HTML object defined on the HTML page.
Parameters
viewContainer
Object. A document object that references the <div> element that holds the viewer.
viewContainerId
String. The value of the id parameter for the <div> element that holds the viewer.
Example
To assign the viewer to display in a <div id='containerName' /> tag on the page, use the following constructor call:
var myViewer = new actuate.Viewer("containerName");
void Viewer.downloadReport(string format, string pages, actuate.viewer.RenderOptions renderoption)
Exports the report with a specified format. The downloadReport function does not return any object. The report is exported to the client side. Then the browser opens a download window for the user to specify a location for the report.
Parameters
format
String. The format in which to export the report. Valid values and their corresponding formats are:
doc: Word
docx: Word 2007
html: HTML-encoded web page
ppt: PowerPoint
pptx: PowerPoint 2007
pdf: Adobe PDF
ps: PostScript
xls: Excel
xlsx: Excel 2007
pages
String. The pages to retrieve. Indicate page ranges by using the first page number of the range and the last page number separated by a dash. To use more than one value, separate individual page numbers or page ranges with commas.
renderoption
actuate.viewer.RenderOptions object. Optional. Sets the rendering options for the download, which currently only applies to multisheet xls format reports.
Example
To download the first five pages of the report in the viewer, use the following code:
viewer.downloadReport("pdf", "1-5", null);
downloadResultSet
Syntax
void Viewer.downloadResultSet(actuate.data.Request request, function callback)
Gets all the data from the report as specified by the request. This function makes an AJAX call to the server for the data that is not in the current page. Write a callback function to process the result set. The callback must take an actuate.data.ResultSet object as an argument.
Function. The callback function to call after retrieving the results. The callback function must take an actuate.data.ResultSet object as an argument.
Example
This example creates an actuate.data.ResultSet object from the report in myViewer as specified by myRequest and passes it to a callback function:
myViewer.downloadResultSet(myRequest, callback);
enableIV
Syntax
void Viewer.enableIV(function callback)
Enables interactive viewing features for this Viewer, which enables the selection and modification of report content. This function must be used in the callback of viewer.submit( ) as shown in the following example:
function runInteractive(){
myviewer.setReportName("/Public/BIRT and BIRT Studio Examples
Integer or Object. An integer indicates the same margin on all sides, in pixels. The object contains the pixel values for the top, bottom, left, and right margins of the viewer in an array. For example, a 25-pixel top content margin and no margin in the other directions would be the object array {top:25, left:0, right:0, bottom:0}.
Example
To set the margin of the viewer newViewer to match the margin of myViewer, use code similar to the following:
Returns the report content displayed in the viewer. This function is the entry point for retrieving the report elements from this viewer object.
Returns
actuate.viewer.PageContent object.
Example
Use this function to access the bookmarks for specific elements in the page content. For example, to access the table "mytable" on the page loaded in the myViewer viewer object, use the following code:
var element = myViewer.getCurrentPageContent( )
.getTableByBookmark("mytable");
getCurrentPageNum
Syntax
integer Viewer.getCurrentPageNum( )
Returns the page number for the page currently being displayed.
Returns
Integer. The current page number.
Example
This function is useful to move to another page relative to the current page. To go to the next page in a document, use the following code:
Goes to the specified page. The viewer throws an exception when the page is not found.
Parameter
pageNumber
Integer. A page number in the report.
Example
To go to the first page of a report, use the following code:
viewer.gotoPage(1);
isInteractive
Syntax
boolean Viewer.isInteractive( )
Returns the interactive viewing status of the viewer. Enables or disables the interactive viewing features with actuate.Viewer.enableIV( ).
Returns
Boolean. True when interactive viewing features are enabled.
Example
This example displays an alert box with the interactive status of the viewer:
alert("Interactivity of this viewer is set to " + myViewer.isInteractive( ));
saveReportDesign
Syntax
void Viewer.saveReportDesign(string filename, function callback)
Saves the current viewer content as a report design. The viewer must enable interactive viewing with enableIV( ) prior to saving a report design.
Parameters
filename
String. Sets the name of the saved file. The current file name is used if null. The file name must be a path relative to the viewer’s repository.
callback
Function. Optional. The function to execute after the asynchronous call processing is done. The callback takes the current actuate.Viewer object as an input parameter.
Example
To save the content of the viewer as the report design called NewDesign, use the following code:
myViewer.saveReportDesign("NewDesign");
saveReportDocument
Syntax
void Viewer.saveReportDocument(string filename, function callback)
Saves the current viewer content as a report document. The viewer must enable interactive viewing with enableIV( ) prior to saving a report design.
Parameters
filename
String. Sets the name of the saved file. The current file name is used if null. The file name must be a path relative to the viewer’s repository.
callback
Function. Optional. The function to execute after the asynchronous call processing is done. The callback takes the current actuate.Viewer object as an input parameter.
Example
To save the content of the viewer as the report document called NewDocument, use the following code:
myViewer.saveReportDocument("NewDocument");
setContentMargin
Syntax
void Viewer.setContentMargin(string[ ] margin)
void Viewer.setContentMargin(int margin)
Sets the viewer content margin.
Parameter
margin
Array of strings or integer. Each member of the array is the margin for the top, left, right, and bottom internal margins for the viewer. An integer sets all margins to that value.
Example
To set the internal margin of the viewer to a 10‑pixel buffer, use the following code:
myViewer.setContentMargin(10);
setFocus
Syntax
void setFocus(boolean focus)
Sets the focus for the viewer.
Parameter
focus
Boolean. The viewer’s context menu is in focus when this parameter is set to true.
Example
This example blurs the context menu for the viewer:
viewer.setFocus(false);
setHeight
Syntax
void Viewer.setHeight(integer height)
Sets the viewer height.
Parameter
height
Integer. The height in pixels.
Example
To set the height of the viewer to 600 pixels, use the following code:
viewer.setHeight(600);
setParameters
Syntax
void Viewer.setParameters(string[ ] params)
Sets parameters for executing report using literal string pairs.
Parameter
params
Array of strings. Each string in the array is constructed of name:"value" pairs. Use a literal list, such as {param1:"value1", param2:"value2", … }.
Example
To set the value of a parameter, city, to the value, New York, use the following object literal:
Sets parameter values for executing a report using ParameterValue objects.
Parameter
parameters
Array of actuate.parameter.ParameterValue objects. An array of this kind is returned by actuate.Parameter.downloadParameterValues( ) and is the recommended function for creating the parameters input.
Example
To set the parameter values for a report to the parameters in the pvs array, use this code:
Sets the report document to render in this Viewer.
Parameters
reportFile
String. The report file path for a report document file. To set the version for the report, add a semicolon and the version number. For example, “/Public/BIRT and BIRT Studio Examples/Customer Dashboard.rptdocument;1” retrieves version 1 of Customer Dashboard.rptdocument.
connectionHandle
String. Optional. The unique identifier generated by iHub for a temporary report.
Example
To open the Top 5 Sales Performers report, set the report by name and then call submit( ), as shown in the following example:
viewer.setReportDocument("/Public/BIRT and BIRT Studio Examples
/Top 5 Sales Performers.rptdocument");
viewer.submit( );
setReportletBookmark
Syntax
void Viewer.setReportletBookmark(string bookmark)
Sets the bookmark for the Reportlet rendered.
Parameter
bookmark
String. The bookmark ID used to render the Reportlet. Viewer requires a bookmark to render a Reportlet. Viewer does not support automatically generated generic bookmarks from a BIRT report.
Example
To open the Top 5 Customers Reportlet of the Customer Dashboard, set the Reportlet bookmark by name and then call viewer.submit, as shown in the following example:
viewer.setReportName("/Public/BIRT and BIRT Studio Examples
/Customer Dashboard.rptdocument");
viewer.setReportletBookmark("Top 5 Customers");
viewer.submit( );
setReportName
Syntax
void Viewer.setReportName(string reportFile)
Sets the report file, either a report design or report document, to render in this Viewer.
Parameter
reportFile
String. The report file path for a report design file or report document file. To set the version for the report, add a semicolon and the version number. For example, “/Public/BIRT and BIRT Studio Examples/Customer Dashboard.rptdesign;1” retrieves version 1 of Customer Dashboard.rptdesign.
Example
To open the Top 5 Sales Performers report, set the report by name and then call submit( ), as shown in the following example:
viewer.setReportName("/Public/BIRT and BIRT Studio Examples
Sets the target service URL to which this Viewer links. When the service URL is not set, this Viewer links to the default service URL, which is set on the actuate object.
Parameters
iPortalURL
String. The target Actuate web application URL, either a Java Component or iPortal.
requestOptions
actuate.RequestOptions object. Optional. requestOptions defines URL parameters to send with the authentication request, such as the iHub URL, volume, or repository type. The URL can also include custom parameters.
Example
This example sets the URL for the Actuate iPortal web application service:
Updates and reloads the viewer after submitting requests for the viewer. The submit( ) function triggers an AJAX request for all asynchronous operations. When the server finishes the processing, it returns a response and the results are rendered on the page in the viewer container. Calling submit( ) when a previous submit( ) is pending throws an exception.
Parameters
callback
Function. Optional. The function to execute after the asynchronous call processing is done.
rerun
Boolean. Optional. Indicates whether to re-run the report design when refreshing. Default to true.
Example
To open the Top 5 Sales Performers report, set the report by name and then call submit( ), as shown in the following example:
viewer.setReportName("/Public/BIRT and BIRT Studio Examples