Actuate JavaScript API classes : Class actuate.Viewer

Class actuate.Viewer

Description

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 which 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");

Function summary

Table 4-41 lists actuate.Viewer functions.

Table 4-41  actuate.Viewer functions 
Returns the bookmark of a reportlet displayed in the viewer.
Sets the SVG support flag to enable Scalable Vector Graphics content.
Submits all the asynchronous operations that the user has requested on this viewer and renders the viewer component on the page.

actuate.Viewer.disableIV

Syntax

void Viewer.disableIV(function callback)

Disables the Interactive Viewer features of this Viewer object. This is an asynchronous setting committed by submit( ).

Parameters

callback

Function. The callback function to call after the Interactive Viewer is disabled.

Example

To disable the Interactive Viewer option for myViewer, use code similar to the following:

myViewer.disableIV(function alertUser( ){alert("IV disabled");});

actuate.Viewer.downloadReport

Syntax

void Viewer.downloadReport(string format, string pages)

Export report with 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:

n  
n  
n  
n  
n  
n  
n  
n  

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.

Example

To download the first five pages of the report in the viewer, use the following code:

viewer.downloadReport("pdf", "1-5");

actuate.Viewer.downloadResultSet

Syntax

actuate.data.ResultSet 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.

Parameters

request

actuate.data.Request object. The request for results to fill the result set.

callback

Function. The callback function to call after retrieving the results. The callback function must take an actuate.data.ResultSet object as an argument.

Returns

actuate.data.ResultSet object.

Example

This example creates an actuate.data.ResultSet object called myResultSet that contains the results of the request in the myRequest object from the report in myViewer.

var myResultSet = myViewer.downloadResultSet(myRequest, null);

actuate.Viewer.enableIV

Syntax

void Viewer.enableIV(function callback)

Enable interactive viewing features for this viewer, which enables the selection and modification of report content. Call this function before calling actuate.Viewer.getCurrentPageContent( ) to access and modify the report content.

Parameters

callback

Function. The callback function to call after enabling the interactive viewer features.

Example

To enable the Interactive Viewer option for myViewer, use code similar to the following:

myViewer.enableIV(function alertUser( ){alert("IV enabled");});

actuate.Viewer.getChart

Syntax

actuate.report.Chart Viewer.getChart(string bookmark)

Returns an instance of the chart referenced by a bookmark.

Parameters

bookmark

String. The bookmark name.

Returns

actuate.report.Chart object.

Example

This example returns the chart with the bookmark ChartBookmark.

function getMyChartByBookmark(myReport) {
  var bviewer = myReport.getViewer("Chart");
  var bpagecontents = bviewer.getCurrentPageContent( );
  return bpagecontents.getChart("ChartBookmark");
}

actuate.Viewer.getClientHeight

Syntax

integer Viewer.getClientHeight( )

Get the browser window’s height.

Returns

Integer. Height in pixels.

Example

To reset the viewer height to 20 pixels less than the browser window if it is larger than the browser window, use code similar to the following:

if(myViewer.getClientHeight( ) < myViewer.getHeight( )){
  myViewer.setHeight(myViewer.getClientHeight( ) - 20);
}

actuate.Viewer.getClientWidth

Syntax

integer Viewer.getClientWidth( )

Get the browser window’s width.

Returns

Integer. Width in pixels.

Example

To reset the viewer width to 20 pixels less than the browser window if it is larger than the browser window, use code similar to the following:

if(myViewer.getClientWidth( ) < myViewer.getWidth( )){
  myViewer.setWidth(myViewer.getClientWidth( ) - 20);
}

actuate.Viewer.getContentByBookmark

Syntax

void Viewer.getContentByBookmark(string bookmark, string format, function callback)

Get the report content by bookmark and passes the content as data to the callback.

Parameters

bookmark

String. The bookmark of a report element to retrieve.

format

String. The Output format, which is either html or xhtml.

callback

Function. Callback to be called once the operation is finished. The callback must take actuate.data.ReportContent object as an argument.

Example

To retrieve the content with the bookmark FirstChart as html, use code similar to the following:

myViewer.getContentByBookmark("FirstChart", "html", processChart);

actuate.Viewer.getContentByPageRange

Syntax

void Viewer.getContentByPageRange(string PageRange, string format, function callback)

Get the report content by Page Range and passes the content as data to the callback.

Parameters

PageRange

String. PageRange to retrieve the report content.

format

String. The Output format, which is either html or xhtml.

callback

Function. Callback to be called once the operation is finished. The callback must take actuate.data.ReportContent object as an argument.

Example

To retrieve the content from pages 3 through 5 as html, use code similar to the following:

myViewer.getContentByPageRange("3-5", "html", processPages);

actuate.Viewer.getContentMargin

Syntax

object Viewer.getContentMargin( )

Gets the viewer content margin.

Returns

Object. 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:

newViewer.setContentMargin(myViewer.getContentMargin( ));

actuate.Viewer.getCurrentPageContent

Syntax

actuate.viewer.Content Viewer.getCurrentPageContent( )

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.Content 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");

actuate.Viewer.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:

viewer.gotoPage(viewer.getCurrentPageNum( ) + 1);

actuate.Viewer.getDataItem

Syntax

actuate.report.DataItem Viewer.getDataItem(string bookmark)

Returns an instance of report data referenced by a bookmark.

Parameters

bookmark

String. The bookmark name.

Returns

actuate.report.DataItem object.

Example

To get the report data with the bookmark FirstDataItem and store it in the variable myDataItem, use code similar to the following:

var myDataItem = myViewer.getDataItem("FirstDataItem");

actuate.Viewer.getFlashObject

Syntax

actuate.report.FlashObject Viewer.getFlashObject(string bookmark)

Returns an instance of the Flash object referenced by a bookmark.

Parameters

bookmark

String. The bookmark name.

Returns

actuate.report.FlashObject object.

Example

To get the flash object with the bookmark FirstFlashObject and store it in the variable myFlashObject, use code similar to the following:

var myFlashObject = myViewer.getFlashObject("FirstFlashObject");

actuate.Viewer.getGadget

Syntax

actuate.report.Gadget Viewer.getGadget(string bookmark)

Returns an instance of the gadget referenced by a bookmark.

Parameters

bookmark

String. The bookmark name.

Returns

actuate.report.Gadget object.

Example

To get the gadget with the bookmark FirstGadget and store it in the variable myGadget, use code similar to the following:

var myGadget = myViewer.getGadget("FirstGadget");

actuate.Viewer.getHeight

Syntax

string Viewer.getHeight( )

Returns the height value of the viewer.

Returns

String.

Example

This example decreases the viewer’s height by 10.

var height = myViewer.getHeight( );
myViewer.setHeight(height - 10);

actuate.Viewer.getHelpBase

Syntax

string Viewer.getHelpBase( )

Returns the URL of the help base. The help base is the base URL for the product help documentation.

Returns

String. The URL where the help documentation is located.

Example

This example displays the help base URL in an alert box.

alert("The help base URL is " + myViewer.getHelpBase( ))

actuate.Viewer.getId

Syntax

string Viewer.getId( )

Returns the ID for the viewer object.

Returns

String.

Example

This example returns the myViewer object’s ID in an alert box.

alert("The viewer's ID is " + myViewer.getId( ));

actuate.Viewer.getIportalUrl

Syntax

string Viewer.getIportalUrl( )

Returns the Actuate web application URL set in this viewer object.

Returns

String.

Example

This example returns the Actuate web application URL in an alert box.

alert("The web application URL is " + myViewer.getIportalUrl( ));

actuate.Viewer.getLabel

Syntax

actuate.report.Label Viewer.getLabel(string bookmark)

Returns an instance of the label referenced by a bookmark.

Parameters

bookmark

String. The bookmark name.

Returns

actuate.report.Label object.

Example

To get the label with the bookmark FirstLabel and store it in the variable myLabel, use code similar to the following:

var myLabel = myViewer.getLabel("FirstLabel");

actuate.Viewer.getReportletBookmark

Syntax

string Viewer.getReportletBookmark( )

Returns the bookmark of the current report page or element.

Returns

String. Bookmark.

Example

This example displays the bookmark of the current report page in an alert box.

alert ("Report bookmark is " + myViewer.getReportletBookmark( ));

actuate.Viewer.getReportName

Syntax

string Viewer.getReportName( )

Returns the name of the report file, either a report design file or report document file, that is currently displayed in this viewer.

Returns

String.

Example

This example displays the currently displayed report file name in an alert box.

alert ("Currently displaying " + myViewer.getReportName( ));

actuate.Viewer.getRequestOptions

Syntax

actuate.RequestOptions Viewer.getRequestOptions( )

Returns the RequestOptions set in this Viewer object. This function returns null when no RequestOptions object is set.

Returns

actuate.RequestOptions object.

Example

To alert the user of the locale setting for the request, use code similar to the following:

alert ("Currently locale: " + myViewer.getRequestOptions( ).getLocale( ));

actuate.Viewer.getTable

Syntax

actuate.report.Table Viewer.getTable(string bookmark)

Returns an instance of the table referenced by a bookmark.

Parameters

bookmark

String. The bookmark name.

Returns

actuate.report.Table object.

Example

To get the table with the bookmark FirstTable and store it in the variable myTable, use code similar to the following:

var myTable = myViewer.getTable("FirstTable");

actuate.Viewer.getText

Syntax

actuate.report.Text Viewer.getText(string bookmark)

Returns an instance of the text object referenced by a bookmark.

Parameters

bookmark

String. The bookmark name.

Returns

actuate.report.Text object.

Example

To get the text object with the bookmark Title and store it in the variable myText, use code similar to the following:

var myText = myViewer.getText("Title");

actuate.Viewer.getTotalPageCount

Syntax

integer Viewer.getTotalPageCount( )

Returns the total number of pages in the report being viewed.

Returns

Integer.

Example

This function is useful to move to the last page of a document. To go to the last page in a document, use the following code:

viewer.gotoPage(viewer.getTotalPageCount( ));

actuate.Viewer.getUIConfig

Syntax

actuate.viewer.UIConfig Viewer.getUIConfig( )

Returns the current UI configuration.

Returns

actuate.viewer.UIConfig object. This function returns null when no UIConfig object is set.

Example

To retrieve and store the content pane from the viewer, use the following code:

var contentpane = viewer.getUIConfig( ).getContentPane( );

actuate.Viewer.getUIOptions

Syntax

actuate.viewer.UIOptions Viewer.getUIOptions( )

Returns the UIOptions set in this Viewer object. This function returns null when no UIOptions object is set.

Returns

actuate.viewer.UIOptions object.

Example

To retrieve and store the uiOptions for the viewer, use the following code:

var options = myViewer.getUIOptions( );

actuate.Viewer.getViewer

Syntax

actuate.Viewer Viewer.getViewer(string bookmark)

Returns a Viewer object containing the report element that is associated with the bookmark. This function returns null when the bookmark is not found.

Parameters

bookmark

String. The bookmark of the report element to view.

Returns

actuate.Viewer object

Example

This example uses getViewer( ) to retrieve a report element and return the bookmark of the chart in that report.

function chartBookmark(myReport){
  var bviewer = myReport.getViewer("Chart");
  var bpagecontents = bviewer.getCurrentPageContent( );
  return bpagecontents.getChartByBookmark("ChartBookmark");
}

actuate.Viewer.getWidth

Syntax

string Viewer.getWidth( )

Returns the width value of the viewer.

Returns

String.

Example

This example decreases the viewer’s width by 10.

var width = myViewer.getWidth( );
myViewer.setWidth(width - 10);

actuate.Viewer.gotoBookmark

Syntax

void Viewer.gotoBookmark(string bookmark)

Goes to the page position by the specified bookmark. The viewer displays to the first page when the bookmark is not found.

Parameters

bookmark

String. The bookmark of a report element.

Example

To move the viewer to the page position specified by the value of the ‘bookmark’ parameter, use this code:

viewer.gotoBookmark(document.getElementById('bookmark').value);

actuate.Viewer.gotoPage

Syntax

void Viewer.gotoPage(integer pageNumber)

Goes to the specified page. The viewer throws an exception when the page is not found.

Parameters

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);

actuate.Viewer.isInteractive

Syntax

boolean Viewer.isInteractive( )

Returns the interactive viewing status of the viewer. Enable or disable 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( ));

actuate.Viewer.saveReportDesign

Syntax

void Viewer.saveReportDesign(string filename, function callback)

Saves the current viewer content as 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");

actuate.Viewer.saveReportDocument

Syntax

void Viewer.saveReportDocument(string filename, function callback)

Saves the current viewer content as a report document.

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");

actuate.Viewer.setContentMargin

Syntax

void Viewer.setContentMargin(string[ ] margin)

Sets the viewer content margin.

Parameters

margin

Array of Strings. Each member of the array is the margin for the top, left, right, and bottom internal margins for the viewer.

Example

To set the internal margin of the viewer to a 10 pixel buffer, use the following code:

myViewer.setContentMargin({top:25, left:0, right:0, bottom:0});

actuate.Viewer.setFocus

Syntax

void setFocus(boolean focus)

Sets the focus for the viewer.

Parameters

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);

actuate.Viewer.setHeight

Syntax

void Viewer.setHeight(integer height)

Sets the viewer height.

Parameters

height

Integer. The height in pixels.

Example

To set the height of the viewer to 600 pixels, use the following code:

viewer.setHeight(600);

actuate.Viewer.setHelpBase

Syntax

void Viewer.setHelpBase(string helpBase)

Sets the URL of the help base. The help base is the base URL for the product help documentation.

Parameters

helpBase

String. The URL where the help documentation is located.

Example

This example sets the help base URL to http://www.actuate.com/documentation/R11.

myViewer.setHelpBase("http://www.actuate.com/documentation/R11");
myViewer.submit( );

actuate.Viewer.setParameters

Syntax

void Viewer.setParameters(string[ ] params)

Sets parameters for executing report using literal string pairs.

Parameters

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:

viewer.setParameters({ city:"New York"});

actuate.Viewer.setParameterValues

Syntax

void Viewer.setParameterValues(actuate.parameter.ParameterValue[ ] parameters)

Sets parameter values for executing a report using ParameterValue objects.

Parameters

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:

viewer.setParameterValues(pvs);

actuate.Viewer.setReportletBookmark

Syntax

void Viewer.setReportletBookmark(string bookmark)

Sets the bookmark for the Reportlet rendered.

Parameters

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( );

actuate.Viewer.setReportName

Syntax

void Viewer.setReportName(string reportFile)

Sets the report file, either a report design or report document, to render in this viewer.

Parameters

reportFile

String. The report file path for a report design file or report document file.

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/Top 5 Sales Performers.rptdesign");
viewer.submit( );

actuate.Viewer.setService

Syntax

void Viewer.setService(string iPortalURL, actuate.RequestOptions requestOptions)

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 Information Console.

requestOptions

actuate.RequestOptions object. Optional. RequestOptions defines URL parameters to send with the authentication request, such as the iServer URL, Encyclopedia volume, or repository type. The URL can also include custom parameters.

Example

This example sets the URL for the Actuate iPortal web application service.

myViewer.setService("http://localhost:8700/iportal", myRequestOptions);

actuate.Viewer.setSize

Syntax

void Viewer.setSize(integer width, integer height)

Resizes the viewer’s width and height.

Parameters

width

Integer. The new width is specified in pixels.

height

Integer. The new height is specified in pixels.

Example

To set the viewer’s size to 300 pixels by 300 pixels, use code similar to the following:

myViewer.setSize(300, 300);

actuate.Viewer.setSupportSVG

Syntax

void Viewer.setSupportSVG(boolean usvgFlag)

Controls Scalable Vector Graphics support for the viewer.

Parameters

svgFlag

Boolean. True enables SVG support.

Example

To disable SVG support for the myViewer viewer, use code similar to the following:

myViewer.setSupportSVG(false);

actuate.Viewer.setUIOptions

Syntax

void Viewer.setUIOptions(actuate.viewer.UIOptions options)

Sets the UI options for the viewer using a actuate.viewer.UIOptions object.

Parameters

options

actuate.viewer.UIOptions object. Enables or disables various controls and features.

Example

To hide the toolbar for the viewer, use the following code:

uioptions.enableToolBar(false);
viewer.setUIOptions(uioptions);
viewer.submit( );

actuate.Viewer.setViewingMode

Syntax

void Viewer.setViewingMode(string viewer)

Sets the dashboard viewing mode.

Parameters

viewer

actuate.Constant.ViewingMode constant. Legal values are NON_DASHBOARD, DASHBOARD_NORMAL, and DASHBOARD_MAX

Example

To display content without dashboard features, use the following code:

viewer.setViewingMode(actuate.Constant.ViewingMode.NON_DASHBOARD);

actuate.Viewer.setWidth

Syntax

void Viewer.setWidth(string width)

Sets the viewer width.

Parameters

width

String.

Example

To set the width of the viewer to 800 pixels, use the following code:

viewer.setWidth(800);

actuate.Viewer.showDownloadReportDialog

Syntax

void Viewer.showDownloadReportDialog( )

Displays the export report dialog window.

Example

Use this code to display the report dialog window:

viewer.showDownloadReportDialog( );

actuate.Viewer.showDownloadResultSetDialog

Syntax

void Viewer.showDownloadResultSetDialog( )

Displays the download result set dialog window.

Example

Use this code to display the result set download dialog window:

viewer.showDownloadResultSetDialog( );

actuate.Viewer.showParameterPanel

Syntax

void Viewer.showParameterPanel( )

Displays the parameter panel.

Example

Use this code to display the parameter panel:

viewer.showParameterPanel( );

actuate.Viewer.showPrintDialog

Syntax

void Viewer.showPrintDialog( )

Displays the print dialog window.

Example

Use this code to display the print dialog window:

viewer.showPrintDialog( );

actuate.Viewer.submit

Syntax

void Viewer.submit(function callback)

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. The function to execute after the asynchronous call processing is done.

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/Top 5 Sales Performers.rptdesign");
viewer.submit( );

(c) Copyright Actuate Corporation 2011