Start page
Start page

Start page / Template development / ContentCreator / JavaScript API / Common Functionality

JavaScript API: Common Functionality

JavaScript object: top.WE_API.Common
Developer API documentation: Common

The JavaScript API's Common object provides basic functionality for interaction with the client's user interface:

  • Displaying information
  • Navigating in the preview
  • Executing Java code

Displaying Information

Message Boxes

A simple message box

void showMessage(String text) displays a simple message box with an "OK" button.

Aside from a message text, the message box is not configurable. It is always drawn as an "Information" message pop-up; its button configuration cannot be changed.

<script type="text/javascript">

top.WE_API.Common.showMessage("I am a sample message box.");

</script>

Dialogs

A custom dialog

Dialog frames provide a powerful means of interaction with ContentCreator users, as these frames allow display of custom HTML, including full-featured, interactive applications.

Dialog createDialog() obtains a configurable dialog object that is hidden by default.

<script type="text/javascript">

var myDialog = top.WE_API.Common.createDialog();

// The dialog is still hidden.
// Configuration and display is described in the section "Dialogs".

</script>

The Dialog object obtained in this code segment can be configured and finally displayed to the user. This object is described in detail in the section Dialogs.

Obtaining the Current Preview Element

 

FSID getPreviewElement() provides an object that indicates the store element associated with the current preview. This store element will in most cases be a PageRef or a Dataset element.

<script type="text/javascript">

var previewElement = top.WE_API.Common.getPreviewElement();

</script>

Navigating in the Preview

Two functions provide means to trigger navigation in the preview.

void jumpTo(FSID fsid) accepts an FSID object (obtained with the function getPreviewElement()) to navigate to that object in the preview.

void jumpTo(JavaScriptObject fsid) accepts a JSON-formatted object to navigate to that object in the preview:

<script type="text/javascript">

// Jump to a store element, in this case, a site store element with ID 47.
top.WE_API.Common.jumpTo({"id":47, "store":"SITESTORE"});

// Jump to a dataset with the content ID 128, using a page reference with ID 47.
top.WE_API.Common.jumpTo({"contentId":128, "pageref":47});

// Jump to a dataset with the content ID 128, using the preview page reference of a Content2 node with ID 243.
top.WE_API.Common.jumpTo({"contentId":128, "content2":243});

// Jump to a dataset with the content ID 128, using the preview page reference of a template with ID 17.
top.WE_API.Common.jumpTo({"contentId":128, "template":17});

</script>

The JavaScriptObject always specifies two key/value pairs.

This combination defines either the store element or the dataset that should be displayed in the preview; in the case of datasets, it also specifies which page reference should be used to display the dataset.

Store elements

Required keys:

  • id specifies the target store element's unique ID as a long
  • store specifies the element's store in capital letters (see Store.Type)

Datasets

Required key:

  • contentId specifies the ID of the dataset

Additionally, one of these keys must be specified:

  • content2 specifies the data source, based on which a preview page reference is identified
  • pageref specifies the page reference that should be used to display the dataset
  • template specifies a table template which provides the preview page reference

© 2005 - 2015 e-Spirit AG | All rights reserved. | Last change: 2014-10-08