Anda di halaman 1dari 9

Overview

The ActuateExplorer is an extension to the Actuate JSAPI to allow web page


developers the ability to embed the ability to browse for and select reports directly
in a web page. The Actuate Explorer provides a view of the Actuate Encyclopedia or
file system repository in a tree structure and allows you to wire it up to other
Actuate JSAPI components, such as the Viewer control. If you don’t want to use the
default tree structure, you can get the XML data and populate your own control
such as a drop down list.

Installation
The ActuateExplorer can be used with the Actuate iServer, iServer Express, and
BIRT Deployment Kit.

iServer and iServer Express


The directories below are relative to where the iServer or iServer Express has been
installed. The default installation for the iServer on Windows is C:\Program
Files\Actuate10\iServer and is represented below by SERVER_HOME.

• Copy actuateExplorer.js to SERVER_HOME


\servletcontainer\iportal\iportal\jsapi

• Extract YUI.zip to SERVER_HOME \servletcontainer\iportal\iportal\jsapi


• Copy ActuateExplorer.jar to SERVER_HOME \servletcontainer\iportal\WEB-
INF\lib

• Copy idapi-client.jar to SERVER_HOME \servletcontainer\iportal\WEB-INF\lib

• Modify SERVER_HOME \servletcontainer\iportal\WEB-INF\web.xml to include


the following in the appropriate section of the file (the servlet block should be
inserted with the existing servlet blocks, and the servlet-mappings should be
inserted with the existing servlet-mappings):

<servlet>
<description></description>
<display-name>ActuateExplorer</display-name>
<servlet-name>ActuateExplorer</servlet-name>
<servlet-class>com.actuate.jsapiexplorer.ActuateExplorer</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>ActuateExplorer</servlet-name>
<url-pattern>/actuateExplorerXmlProvider</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>ActuateExplorer</servlet-name>
<url-pattern>/actuateExplorer</url-pattern>
</servlet-mapping>

• Restart the iServer

BIRT Deployment Kit


The BIRT Deployment Kit is a web application deployed as a WAR file to an
application server such as Tomcat, JBoss, WebSphere, WebLogic, etc. The
directories below are relative to the where you unpack the directory in the first
bullet point below. The name of the file you downloaded from BIRT Exchange is to
get the BIRT Deployment Kit should be ActuateJavaComponent.war (as of 11/1/2009
for version 10 SP1).

• Unpack the WAR file to a temporary directory

• Copy actuateExplorer.js to iportal/jsapi

• Extract YUI.zip to iportal/jsapi

• Copy ActuateExplorer.jar to WEB-INF/lib

• Copy idapi-client.jar to WEB-INF/lib

• Modify WEB-INF/web.xml to include the following in the appropriate section of


the file (the servlet block should be inserted with the existing servlet blocks,
and the servlet-mappings should be inserted with the existing servlet-
mappings):
<servlet>
<description></description>
<display-name>ActuateExplorer</display-name>
<servlet-name>ActuateExplorer</servlet-name>
<servlet-class>com.actuate.jsapiexplorer.ActuateExplorer</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>ActuateExplorer</servlet-name>
<url-pattern>/actuateExplorerXmlProvider</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>ActuateExplorer</servlet-name>
<url-pattern>/actuateExplorer</url-pattern>
</servlet-mapping>

• Repackage the war file and deploy to your application server

Using ActuateExplorer in a Web Page


To use the ActuateExplorer in a web page, you need to include control with a script
tag similar to the following:

<script src="http://mycomputer:8080/ajc/actuateExplorer"></script>
This must be included in the web page after inclusion of the Actuate JSAPI. After
initializing the Actuate JSAPI, you must also initialize the Actuate Explorer. The
JavaScript code to load the extension looks like:

actuate.loadExt(callback)

You may also want to simply call embed the initialization of the ActuateExplorer into
the callback function of the Actuate JSAPI initialization, thus chaining the
initialization. The JavaScript code for this type of approach would look something
like:

actuate.initialize(url, reqOptions, "user", "password", (function()


{actuate.loadExt(afterInit);}));

Once the library has been initialized, you can create a new ActuateExplorer and
pass in the appropriate values for the constructor (see ActuateExplorer Constructor
below). Note that if you do not want to display the tree structure, simply omit the
divId in the constructor. The XML data will still be available for use in the web page
by calling either getTextData or getXmlData. After creating the ActuateExplorer,
you may now set preferences such as height, width, repository type, etc. Once all
the preferences have been set, you will need to call the submit method of the
ActuateExplorer.

See the example at the end of this document.


Actuate Explorer JavaScript Reference

Actuate Explorer Initialization


actuate.loadExt(callback) – This must be called after initializing the Actuate
JSAPI. This loads required libraries and styles needed by the ActuateExplorer

ActuateExplorer Constructor
• new ActuateExplorer(divId, icURL, user, password, rootDir, clickFunction)

o divId – The id div where the tree control should be placed. Pass a null
value and no tree control will be rendered, but the XML data will be
available.

o icURL – The URL of the Information Console (or Actuate Java


Components). This should point to the same server, port and context
where the application is deployed.

o user – Only used in conjunction with enterprise mode (iServer or


iServer Express) deployments. Other deployments pass null or empty
stings. Security can be overridden for all types of deployments.

o password – Only used in conjunction with enterprise mode (iServer or


iServer Express) deployments. Other deployments pass null or empty
stings. Security can be overridden for all types of deployments.

o rootDir – The root directory to be processed. Pass "/" for the root of
the repository or encyclopedia.

o clickFunction – The function to call when the user clicks on a report


design (rptdesign) or report document (rptdocument). The fully
qualified path the report will be passed to the function.

ActuateExplorer Methods
• getTextData() – Returns a String representation of the XML data which
represents the repository or encyclopedia.

• getXmlData() – Returns an XMLDocumnet Object representation of the


XML data which represents the repository or encyclopedia.

• setHideExtension(hideExtension) – Used to set whether or not the file


extension (rptdesign or rptdocument) will be displayed in the tree view.
Default is false.
o hideExtention – Boolean – Show or hide file extension.

• setHeight (height) – Used to set height of the tree control

o height – integer – Height.

• setWidth (width) – Used to set the width of the tree control

o width – integer – Width.

• setFontSize (fontSize) – Used to set font size used in the tree view. The
value passed should be a positive integer representing a percentage of
font size. Default font size is 100.

o fontSize – integer – Font size in percent.

• setRepositoryType (repositoryType) – Used to set the type of repository


being used. The only choices are workgroup or enterprise. Default is
workgroup.

o repositoryType – string – Repository Type (workgroup or


enterprise).

• setServerUrl (serverUrl) – Used to set the SOAP port used by the iServer.
This is only used when working the repository type has been set to
enterprise

o serverUrl – string – The iServer URL for SOAP communication.

• setVolume(volumeName) – Used with iServer Enterprise when the desired


encyclopedia volume is not the default volume. If using the default
volume, this parameter is optional.

• setSecurityAdapter(securityAdapter) – Used to set the Java class name of


the security adapter to be used.

o securityAdapter – string – Java class name


• submit(callback) – Submits the request to gather the gather the repository
/ encyclopedia data.

o callback – The method to be called after the submit method.

Security Extension Points


The ActuateExplorer offers two different security extension points. One is for
iServer and iServer Express, and the other is for use with the BIRT Deployment Kit.
These extension points allow you to create seamless integration between your
application, and the ActuateExplorer. In order to implement either of these
extension points, you must implement the appropriate interface.

Encyclopedia Security Adapter


To implement a security adapter for use with the iServer platforms, you must create
a Java class that implements the EncyclopediaSecurityAdapter interface. The
implementing class has access to the HttpServletRequest object and is responsible
for returning an ActuateSession object.

(Note: The ActuateExplorer uses a web service wrapper to communicate with the
Actuate iServer that is available on BIRT Exchange. For more information about this
wrapper, see http://www.birt-exchange.org/devshare/deploying-birt-reports/455-
java-client-for-the-idapi/#description)

The following is a basic example of a class that implements the


EncyclopediaSecurityAdapter
import java.net.MalformedURLException;
import java.net.URL;

import javax.servlet.http.HttpServletRequest;

import com.actuate.idapi.client.ActuateSession;
import com.actuate.idapi.client.ActuateSessionException;
import com.actuate.idapi.client.ActuateSessionFactory;
import com.actuate.jsapiexplorer.EncyclopediaSecurityAdapter;
import com.actuate.jsapiexplorer.ActuateExplorerException;

public class MyEncyclopediaAdapter implements EncyclopediaSecurityAdapter {

public ActuateSession getEncyclopediaSession(HttpServletRequest request)


throws ActuateExplorerException {
ActuateSessionFactory factory = new ActuateSessionFactory();
ActuateSession session = null;
String serverUrl = "http://mycomputer:8000";
String user = (String) request.getSession().getAttribute("myappUserId");
String encryptedpassword = (String) request.getSession().getAttribute(
"myappPassword");
String password = MyAppPasswordProcessor.getPassword(encryptedpassword);
if (serverUrl != null) {
URL endpoint = null;
try {
endpoint = new URL(serverUrl);
} catch (MalformedURLException e) {
throw new ActuateExplorerException("Invalid server URL: "
+ serverUrl, e);
}
factory.setDefaultEndpoint(endpoint);
}
if (user != null)
factory.setDefaultUser(user, password);
try {
session = factory.login();
} catch (ActuateSessionException e) {
throw new ActuateExplorerException("Login failed: "
+ e.getMessage(), e);
}
return session;
}
}

Repository Security Adapter


To implement a security adapter for use with the BIRT Deployment Kit, you must
create a Java class that implements the RepositorySecurityAdapterinterface. The
implementing class has access to the HttpServletRequest object and the XML
representing the file system repository. The adapter is responsible for returning a
filtered XML Structure that follows the same structure as the XML which was passed
in. This security adapter simply gives you the ability to filter the XML before it is
returned to the ActuateExplorer.

Sample XML
The following sample XML shows what the XML used by and returned by the
ActuateExplorer looks like. Notice a directory can contain both directories and files
and the directory tag is not ended until all the containing elements have been
described. If your application is using a RepositorySecurityAdapter, or simply
access the XML Data and using the information to create your own control, this is
what the structure will look like.

<?xml version="1.0"?>
<repository>
<directory>
<name>Home</name>
<repositoryPath>/Home</repositoryPath>
<directory>
<name>administrator</name>
<repositoryPath>/Home/administrator</repositoryPath>
<file>
<name>Customer Dashboard.rptdesign</name>
<type>rptdesign</type>
<path>/Home/administrator</path>
</file>
<file>
<name>Customer Order History.rptdesign</name>
<type>rptdesign</type>
<path>/Home/administrator</path>
</file>
</directory>
<file>
<name>Customer Dashboard.rptdesign</name>
<type>rptdesign</type>
<path>/Home</path>
</file>
</directory>
</repository>

Sample Web Page using the ActuateExplorer


The following is a sample HTML page can be used to test this application.
Alterternatively, you can test with the HTML page and CSS that are provided as part
of this download in the Test folder. This page makes use of the Actuate Explorer
and the Actuate JavaScript API (JSAPI) to allow you to select reports, dynamically
input report parameters and view the report. Make sure to place both the HTML
and CSS files in the same directory.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"


"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script src="http://mycomputer:8900/iportal/jsapi"></script>
<script src="http://mycomputer:8900/iportal/actuateExplorer"></script>
<script type="text/javascript">
var myViewer;
var a;
function acload() {
actuate.load("viewer");
var reqOps = new actuate.RequestOptions( );
reqOps.setRepositoryType(actuate.RequestOptions.REPOSITORY_ENCYCLOPEDIA);
reqOps.setIServerUrl('http://mycomputer:8000');
reqOps.setVolume('rmurphy');
actuate.initialize("http://mycomputer:8900/iportal", reqOps, "Administrator",
"", clickOnReport);
}
function clickOnReport(path){
myViewer.setReportName(path);
myViewer.submit();
}
var a = null;
function afterInit(){
a = new actuateExplorer('TreeDiv', 'http://mycomputer:8900/iportal',
'Administrator', '', '/', clickOnReport);
a.setHeight(400);
a.setWidth(400);
a.setFontSize(90);
a.setRepositoryType('enterprise');
a.setServerUrl('http://mycomputer:8000');

a.submit(displayXml);

myViewer = new actuate.Viewer("ViewerDiv");


var uiopts = new actuate.viewer.UIOptions();
uiopts.enableToolBar(false);
myViewer.setUIOptions(uiopts);
}
function displayXml(){
alert(a.getTextData());
}

</script>
</head>

<body onload="acload()">
<table><tr><td style="vertical-align:top;">
<div id='TreeDiv'></div>
</td><td>
<div id='ViewerDiv'></div>
</td></tr></table>
</body>
</html>