28 Sites SDK Reference

The Oracle Content Management JavaScript SDK (Sites SDK) has a set of functions that enable components to have a more integrated experience with Oracle Content Management.

The Sites SDK is available for download from the Oracle Content Management server:

http://{server}/_sitesclouddelivery/renderer/app/sdk/js/sites.min.js

The Sites Application Programming Interface (API) definitions cover all defined namespaces of the global object SitesSDK:

The main purpose of the Sites SDK is to enable users to build and manage applications. It provides several features:

  • Communication across inline frame and domain boundaries

    • Enables a component to communicate with a page regardless of where the component is hosted

    • Includes participation in the page model life cycle:
      • creating the component

      • rendering the component with stored properties

      • updating the component and saving those changes

      • deleting the component from the page

    • Stores and retrieves custom settings used to configure a component for use in a page

    • Uses intercomponent communication to take part in triggers and actions

  • Geometry hints to a page (doesn’t apply to custom components)

    • Enables a page to dynamically resize the inline frame when told to do so by a component

    • Results in a component appearing to be part of a page, and the page moving in response to component resize events (no scroll bars)

  • Component awareness of when it is called by Oracle Content Management

    • Communication between a component and a page contains a token signed by a private key.

    • Sites SDK enables a component to decode the token and facilitate verification of the caller.

You include Sites SDK functions by providing a known path of the script. For example:

<script type="text/javascript" 
src="<sdk_install_dir_path_prefix>/sites.min.js">
</script>

The Sites SDK has these global objects:

  • SitesSDK

  • SitesSDK.Utils

SitesSDK

The SitesSDK global object can be used in render and settings endpoints.

Command Task

SitesSDK.getProperty(propertyName, callback)

Gets the value of the named property from the host site.

SitesSDK.setProperty(propertyName, propertyValue)

Sets the value of the named property to propertyValue.

SitesSDK.getSiteProperty(propertyName, callback)

Gets a named site property value from the host site. For example, it could fetch the current theme design that is being used by the host site.

SitesSDK.publish(messageType, payload)

Sends a message to the server, and accepts a messageType and JSON object as a payload.

SitesSDK.subscribe(messageType, callback)

A message listener for messages dispatched from the host site. The call is asynchronous. These are JavaScript callbacks, so the function should use JavaScript Closure or suitably bind the function to ensure it has access to the appropriate context.

SitesSDK.Utils

The SitesSDK.Utils namespace has utility functions that can be called by all endpoints of an Oracle Content Management component. This namespace is available for the Settings panel for a remote component, but not for the inline local component.

Caution:

These functions are not officially supported by Oracle; they are intended as sample implementations. Use them at your own risk.
Command Task

SitesSDK.Utils.Logger

Returns the logger object being used by the Sites SDK. The log level can be set to one of these:
  • debug

  • log

  • info

  • error

  • warn

SitesSDK.Utils.addSiteThemeDesign(cssUrl)

Adds the current site theme design to a component.

Utils.getStyle(elem,styleProp)

A utility method that calculates the height of the inline frame.