Opening files from ReportExplorer
The ReportExplorer class generates an actuate.reportexplorer.eventconstants.ON_SELECTION_CHANGED event when the user selects a folder or file in the Report Explorer User Interface. To access the file information in this event, implement an event handler like the one shown in the following code:
explorer.registerEventHandler( actuate.reportexplorer.EventConstants.ON_SELECTION_CHANGED, selectionChanged );The event passes the path and name of the file in the second parameter of the handler, pathName. To access the file, the event handler stores the path in a global variable, file.
In this implementation, the file path is updated each time a file selected. To open the file currently selected, implement a button on the page that runs a separate function that opens the file. The following code example shows a button that calls the custom displayReport( ) function, which attempts to open the file using an actuate.viewer object:
<input type="button" style="width: 150pt;" value="View Report" onclick="javascript:displayReport( )"/>The try-catch block returns to the report explorer if viewer is unable to open the file.
This is a complete example of a ReportExplorer page that opens a file in the BIRT Viewer when the user activates the View Report button:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><input type="button" style="width: 150pt;" value="View Report"onclick="javascript:displayReport( )"/><script type="text/javascript" language="JavaScript" src="http://localhost:8700/iportal/jsapi"></script>
(c) Copyright Actuate Corporation 2011 |
![]() |