Oracle Fusion Middleware Disc API Reference for Oracle WebLogic Portal
10g Release 3 (10.3.4)
E14257-04

Module bea.wlp.disc.context

This module provides contextual information about the rendered Portal. When Disc is enabled for a Portal, instances of context classes are created as part of the Portal rendering process. These context classes provide information about individual Portal components such as Portlets, Pages, Layouts and Themes, as well as information about the relationship between these components. Context (i.e. instances of context objects) is provided only for visible Portal components. Information about non-visible components, such as books peer to the current book or hidden portlets, will not be available via context objects.

A typical usage scenario may look something like the following:

         var portlet = bea.wlp.disc.context.Portlet.findByLabel("myPortlet");
         var title = portlet.getTitle();
         var mode = portlet.getWindowMode();
         var page = portlet.getParentPage();
     

Disc context classes are loosely representative of server-side PresentationContext classes and generally provide similar functionality for use in client-side code. Like server-side PresentationContext objects, the lifecycle of Disc context objects is managed by Portal and application code should generally not attempt to create or destroy such objects. Furthermore, Disc context objects should be considered immutable; functions and/or properties should not be added, and existing properties should not be accessed or manipulated except via the provided APIs.

In addition to creating instances of Disc context objects, enabling Disc also causes Portal to render HTML containers around standard Portal components. This container is a single HTML Element containing all markup for the corresponding component and is sometimes referred to as the "context hook". Like the context objects, the context container element itself should be considered immutable; attributes, styling, event handlers, or other similar functionality and data should not be added to the container element. Furthermore, the context container element should be considered opaque; no meaning should be inferred from the element name, individual attributes/properties or their values. All such information is subject to change without notice. The only supported operations on context container elements are standard DOM mechanisms to retrieve the container's children. Most context objects support a method to retrieve the markup associated with the context's component, and this method will return a reference to the context container element. See the getMarkupElement() method for more information.

Application code should not hold references to Disc context objects beyond the immediate use of such objects. Dynamic updates to the HTML page may make such references stale or invalid.

Disc context objects are generally not available in a valid state until the entire HTML page has been loaded. Application code should not attempt to use context objects from inline script blocks, but should instead register an "onload" handler that encapsulates interaction with context objects. For example, the following code when placed inline in a portlet JSP will not behave as expected:

         var portlet = bea.wlp.disc.context.Portlet.findByLabel("myPortletLabel"); // portlet will be null
         var title = portlet.getTitle(); // error
     
However, if we add the same code via a Dojo (for example) onload function, the code works as expected:
         dojo.addOnLoad(function() {
             var portlet = bea.wlp.disc.context.Portlet.findByLabel("myPortletLabel");
             var title = portlet.getTitle();
         });
     

Oracle Fusion Middleware Disc API Reference for Oracle WebLogic Portal
10g Release 3 (10.3.4)
E14257-04

Copyright © 2011, Oracle. All rights reserved.