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
Constructs a new viewer object. The container is an HTML object defined on the HTML page.
Parameters
Object. A document object that references the <div> element which holds the viewer.
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:
Function summary
Table 4-41 lists actuate.Viewer functions.
Table 4-41 actuate.Viewer functions Gets the margin dimensions of the content in pixels. Returns the report content displayed in the viewer. getId( ) Returns the Actuate web application URL that this viewer accesses. Returns the bookmark of a reportlet displayed in the viewer. getText( ) Returns a viewer object containing the given bookmarked element. Goes to the position in the report specified by the bookmark. Returns whetherinteractive viewing features are enabled. Sets the parameters to run a report using a list of literal string pairs. Sets the parameters to run a report using a generated object. setSize( ) Sets the SVG support flag to enable Scalable Vector Graphics content. Enables the download data dialog window. submit( ) 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
Disables the Interactive Viewer features of this Viewer object. This is an asynchronous setting committed by submit( ).
Parameters
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
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
String. The format in which to export the report. Valid values and their corresponding formats are:
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:
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
actuate.data.Request object. The request for results to fill the result set.
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.
actuate.Viewer.enableIV
Syntax
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
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
Returns an instance of the chart referenced by a bookmark.
Parameters
Returns
Example
This example returns the chart with the bookmark ChartBookmark.
actuate.Viewer.getClientHeight
Syntax
Get the browser window’s height.
Returns
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( )){actuate.Viewer.getClientWidth
Syntax
Get the browser window’s width.
Returns
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( )){actuate.Viewer.getContentByBookmark
Syntax
Get the report content by bookmark and passes the content as data to the callback.
Parameters
String. The bookmark of a report element to retrieve.
String. The Output format, which is either html or xhtml.
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:
actuate.Viewer.getContentByPageRange
Syntax
Get the report content by Page Range and passes the content as data to the callback.
Parameters
String. PageRange to retrieve the report content.
String. The Output format, which is either html or xhtml.
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:
actuate.Viewer.getContentMargin
Syntax
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:
actuate.Viewer.getCurrentPageContent
Syntax
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
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:
actuate.Viewer.getDataItem
Syntax
Returns an instance of report data referenced by a bookmark.
Parameters
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:
actuate.Viewer.getFlashObject
Syntax
Returns an instance of the Flash object referenced by a bookmark.
Parameters
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:
actuate.Viewer.getGadget
Syntax
Returns an instance of the gadget referenced by a bookmark.
Parameters
Returns
Example
To get the gadget with the bookmark FirstGadget and store it in the variable myGadget, use code similar to the following:
actuate.Viewer.getHeight
Syntax
Returns the height value of the viewer.
Returns
Example
This example decreases the viewer’s height by 10.
actuate.Viewer.getHelpBase
Syntax
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.
actuate.Viewer.getId
Syntax
Returns the ID for the viewer object.
Returns
Example
This example returns the myViewer object’s ID in an alert box.
actuate.Viewer.getIportalUrl
Syntax
Returns the Actuate web application URL set in this viewer object.
Returns
Example
This example returns the Actuate web application URL in an alert box.
actuate.Viewer.getLabel
Syntax
Returns an instance of the label referenced by a bookmark.
Parameters
Returns
Example
To get the label with the bookmark FirstLabel and store it in the variable myLabel, use code similar to the following:
actuate.Viewer.getReportletBookmark
Syntax
Returns the bookmark of the current report page or element.
Returns
Example
This example displays the bookmark of the current report page in an alert box.
actuate.Viewer.getReportName
Syntax
Returns the name of the report file, either a report design file or report document file, that is currently displayed in this viewer.
Returns
Example
This example displays the currently displayed report file name in an alert box.
actuate.Viewer.getRequestOptions
Syntax
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
Returns an instance of the table referenced by a bookmark.
Parameters
Returns
Example
To get the table with the bookmark FirstTable and store it in the variable myTable, use code similar to the following:
actuate.Viewer.getText
Syntax
Returns an instance of the text object referenced by a bookmark.
Parameters
Returns
Example
To get the text object with the bookmark Title and store it in the variable myText, use code similar to the following:
actuate.Viewer.getTotalPageCount
Syntax
Returns the total number of pages in the report being viewed.
Returns
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:
actuate.Viewer.getUIConfig
Syntax
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
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:
actuate.Viewer.getViewer
Syntax
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
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.
actuate.Viewer.getWidth
Syntax
Returns the width value of the viewer.
Returns
Example
This example decreases the viewer’s width by 10.
actuate.Viewer.gotoBookmark
Syntax
Goes to the page position by the specified bookmark. The viewer displays to the first page when the bookmark is not found.
Parameters
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:
actuate.Viewer.gotoPage
Syntax
Goes to the specified page. The viewer throws an exception when the page is not found.
Parameters
Integer. A page number in the report.
Example
To go to the first page of a report, use the following code:
actuate.Viewer.isInteractive
Syntax
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
Saves the current viewer content as a report design.
Parameters
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.
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:
actuate.Viewer.saveReportDocument
Syntax
Saves the current viewer content as a report document.
Parameters
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.
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:
actuate.Viewer.setContentMargin
Syntax
Sets the viewer content margin.
Parameters
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:
actuate.Viewer.setFocus
Syntax
Sets the focus for the viewer.
Parameters
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.
actuate.Viewer.setHeight
Syntax
Parameters
Integer. The height in pixels.
Example
To set the height of the viewer to 600 pixels, use the following code:
actuate.Viewer.setHelpBase
Syntax
Sets the URL of the help base. The help base is the base URL for the product help documentation.
Parameters
String. The URL where the help documentation is located.
Example
This example sets the help base URL to http://www.actuate.com/documentation/R11.
actuate.Viewer.setParameters
Syntax
Sets parameters for executing report using literal string pairs.
Parameters
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:
actuate.Viewer.setParameterValues
Syntax
Sets parameter values for executing a report using ParameterValue objects.
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:
actuate.Viewer.setReportletBookmark
Syntax
Sets the bookmark for the Reportlet rendered.
Parameters
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");actuate.Viewer.setReportName
Syntax
Sets the report file, either a report design or report document, to render in this viewer.
Parameters
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");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
String. The target Actuate web application URL, either a Java Component or Information Console.
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
Resizes the viewer’s width and height.
Parameters
Integer. The new width is specified in pixels.
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:
actuate.Viewer.setSupportSVG
Syntax
Controls Scalable Vector Graphics support for the viewer.
Parameters
Boolean. True enables SVG support.
Example
To disable SVG support for the myViewer viewer, use code similar to the following:
actuate.Viewer.setUIOptions
Syntax
Sets the UI options for the viewer using a actuate.viewer.UIOptions object.
Parameters
actuate.viewer.UIOptions object. Enables or disables various controls and features.
Example
To hide the toolbar for the viewer, use the following code:
actuate.Viewer.setViewingMode
Syntax
Sets the dashboard viewing mode.
Parameters
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:
actuate.Viewer.setWidth
Syntax
Parameters
Example
To set the width of the viewer to 800 pixels, use the following code:
actuate.Viewer.showDownloadReportDialog
Syntax
Displays the export report dialog window.
Example
Use this code to display the report dialog window:
actuate.Viewer.showDownloadResultSetDialog
Syntax
Displays the download result set dialog window.
Example
Use this code to display the result set download dialog window:
actuate.Viewer.showParameterPanel
Syntax
Example
Use this code to display the parameter panel:
actuate.Viewer.showPrintDialog
Syntax
Displays the print dialog window.
Example
Use this code to display the print dialog window:
actuate.Viewer.submit
Syntax
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
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");
(c) Copyright Actuate Corporation 2011 |
![]() |