Hide menu Last updated: Oct 27 2016
Area: Episerver CMS Applies to versions: 10 and higher
Other versions:

Message service pool

The message service alerts an editor of the current working page status, such as when an editor edits a page property or submits a page for editing.

The message service store uses a central message pool with two main parts:

  • A central message hub service that supports other parts in adding or removing items.
  • A widget container that displays the notification items for a current working page to a user.

Adding message service component

The message service is the central hub which is registered in the Episerver Framework ShellModule.

To refer to the message service, use a dependency to resolve it.

this._messagePool = epi.dependency.resolve("epi.shell.MessageService");

Methods

put: function ( /*String*/typeName,
                /*String*/message,
                /*String*/contextTypeName,
                /*Object*/contextId,
                /*Object*/externalItemId,
                /*Object*/externalItemData) 

remove: function (/*Object?*/query)

query: function (/*Object?*/query)

observe: function (/*Object?*/query, callback)
            

Examples

Add a page property to the message queue

The following example code shows how to to add a page property item error to the global message queue.

this._messagePool.put("error", result.error, "Page", this.pageLink, item.propertyName, item.item);

Remove a page property from the message queue

The following example code shows how to remove a page property item error from the global message queue.

this._messagePool.remove({
    contextTypeName: "Page",
    contextId: this.pageLink,
    externalItemId: item.propertyName,
    externalItemData: item.item });

Query error items in the message queue

The following example code shows how to query error items with a specific contextTypeName and contextId in the global message queue.

this._query = { typeName: "error", contextTypeName: this.contextTypeName, contextId: this.contextId};
var messages = this._messagePool.query(this._query);

Observe a message in the message queue

The following example code shows how to observe a message with a specific contextTypeName and contextId in the global message queue, with query conditions.

this._messagePool.observe({ contextTypeName: messageContext.contextTypeName, contextId: messageContext.contextId });

Message service listener widget

Currently the [NotificationStatusBar] widget is injected to the status bar and observes changes in the message queue related to the current working page. The widget then displays message elements for the current working page, such as errors, warnings and notifications.

Comments