Event API

The Event API provides a set of methods for communication between iViews on the client through a publish-subscribe mechanism. For background information, see
Client-Side Eventing .

EPCM.subscribeEvent( nameSpace, eventName, eventHandler )

Subscribes an event handler to the specified event. Returns the event listener ID as a string.

The EPCF supports the different options to define the event handler in the event subscription by providing the following method signatures:

EPCM.subscribeEvent( nameSpace, eventName, eventHandler )

This method adds the event handler to the subscription list for the event defined by the
nameSpace and the
eventName parameters. The combination of
nameSpace ,
eventName and
eventHandler must
be unique. It is not possible to subscribe the same event handler to several events.

Raises the event defined by
nameSpace and
eventName . The EPCF service calls all event handlers, which are registered for this event, and passes the event object to the event handler.

The event object is created by the EPCF service whenever an event is raised. It combines the
dataObject , the
eventName and the
sourceId (which may be null) parameters into a single argument for the event
handler.

Parameter

Type

Description

nameSpace

String

URN of the event namespace.

eventName

String

The name of the event to be raised

dataObject

Object

An object (string, number, boolean, or object) that contains a description of the event

sourceId

(optional)

String

The component ID of the event source, for example, the ID defined at design-time. Specify
Null or no parameter if you do not need the ID.

You can use the Event API to indirectly raise events from a child window in a parent window that opened it.

To raise an event from a child window in its parent window:

In the parent window, subscribe to an event in a namespace, for example,
MyNewNamespace:

EPCM.subscribe("MyNewNamespace","RefreshInbox", eventHandler);

In the child window, raise the event with the
urn:com.sapportals.portal:childToParents namespace, and the event name, which is a concatenation of the namespace (
MyNewNamespace) and name of the event to which the parent
window is subscribed (
RefreshInbox), joined by
& :

If child windows are opened in a sequence, the event is passed through all the windows in this sequence, but the specified event handler is executed only in the windows that are subscribed to this event.

Related Content

The following content is not part of SAP product documentation. For more information, see the following
disclaimer
.