Pagelet and Portlet Development: Adaptive Pagelets

Using the Common Opener

The Common Opener allows you to open any ALI object from anywhere within the portal. (To retrieve an URL as a String or HTMLAnchor object, use ASURL.)

The PTCommonOpener class is included in every page generated by the ALI application, and can be called from any piece of UI or from within a portlet. Portlets can also call functions remotely through the PRC. The most commonly used function in this class is getOpenerURLOpenObjID.

function getOpenerURLOpenObjID (_nClassID, _nObjectID, _strOptQSArgs, _nOpenerMode)

This JavaScript creates a URL that calls the Opener ActivitySpace and its corresponding OpenObject Control (the only MVC module in the Opener ActivitySpace). The URL includes all necessary parameters for the Control. As noted above, the Common Opener function is available from any portal page. The getOpenerURLOpenObjID function has four required parameters:

As noted above, the getOpenerURLOpenObjID function returns a URL. To open the URL you must pass it to another function. PTCommonOpener includes two handy functions for opening URLs: openInSameWindow and openInNewWindow.

Call either of these functions in a standard OnClick event. The example below opens the User Editor ActivitySpace as the Administrator user in View mode.

<INPUT value="Opener Click" type="Button" name="btnSubmit" onClick="PTCommonOpener.openInSameWindow(PTCommonOpener.getOpenerURLOpenObjID(1,1,'null',2));"/>

You can execute custom functionality whenever the Common Opener is used to open an object or direct to an ActivitySpace through the IOpenerActions PEI. For more details on PTCommonOpener and its functions, see the Common Opener API documentation. To download the samples referenced on this page, see the ALI Scripting Framework Samples in dev2dev code share.

Custom ActivitySpaces and Non-ALI Pages

As noted earlier, PTCommonOpener functions can be called from within any ALI-based portal page.  You can also use these functions in a custom editor or browsing page by making a call to the Opener ActivitySpace.  The Common Opener functionality can be implemented in a variety of ways; the method explained here is the easiest and most commonly used.

Note: To use the following method, first import the package that contains the Opener ActivitySpace (com.plumtree.portaluiinfrastructure.classtypedescriptors.classframework).

Within the DisplayJavaScript method in the View class of your custom ActivitySpace, make a call to GetOpenerJavascript as shown in the code snippet below. This function requires one parameter: the ActivitySpace that contains the JavaScript function (inherited from the top level AActivitySpace object (m_asOwner)). The HTMLScript element returned contains Common Opener JavaScript functions.  

public HTMLScript DisplayJavascript()
{
HTMLScript myScript;
myScript = new HTMLScript("text/javaScript");
myScript = PTOpenerLinks.GetOpenerJavascript(m_asOwner);
return myScript;
}

This code creates a new HTMLScript element, initializes it, and makes a call to GetOpenerJavascript.

Other methods for generating JavaScript code on the server are described in the API documentation for PTOpenerLinks in the portaluiinfrastructure package.

Next: Using ASURL and Redirect