Select language:

Syntax documentation Event API 

The EPCF Event API provides methods for event handling on the client side.

EPCM.subscribeEvent( nameSpace, eventName, eventHandler )

This method assigns an event handler to the specified event.

The method sets the event handler to the subscription list for the event defined by the nameSpace and the eventName. The combination of nameSpace, eventName and eventHandler must be unique. It is not possible to register the same event handler to several events. See section Namespaces for more details.

Caution

Isolated iViews have to subscribe on every page Refresh or Reload.

 

Parameter Description

Parameter

Type

Description

nameSpace

String

URN of the event namespace.

eventName

String

The event name you subscribe to. You can use an asterisk (*) to subscribe for all events of this name-space.

eventHandler

Function

Reference to the event handler.

Usage

<script language ="JavaScript">

  function onWakeup( eventObj ) {

  alert( "got a wakeup call from " +

  eventObj.sourceId + ": " + eventObj.dataObject );

  }

  ...

  EPCM.subscribeEvent( "urn:com.sap:alarmClock",

  "morningCall", onWakeup );

  ...

  EPCM.subscribeEvent( "urn:com.sap:alarmClock", "*", onWakeup );

<script>

 

 

 

EPCM.raiseEvent( nameSpace, eventName, dataObject [, sourceId])

This method 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 on 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) to a single argument for the event handler.

Parameter Description

Parameter

Type

Description

nameSpace

String

URN of the event name-space.

eventName

String

The event name with which the event is 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.

Usage

<SCRIPT language ="JavaScript">

  ...

  EPCM.raiseEvent( "urn:com.sap:alarmClock", "morningCall",

  "Good morning ladies and gentlemen", "iView_0815" );

  ...

<SCRIPT>

 

Raising Events Between Windows

EPCF Event API enables you to 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, call the raiseEvent method with the urn:com.sapportals.portal:childToParent namespace (this namespace is reserved by the portal).

For example:

...

...

  1.  In the parent window, subscribe to an event in the urn:com.sapportals.portal:childToParent namespace:

EPCM.subscribe("urn:com.sapportals.portal:childToParents","RefreshInbox", eventHandler);

  2.  In the child window, raise the event:

EPCM.raiseEvent("urn:com.sapportals.portal:childToParents", "RefreshInbox");

To raise an event from a namespace different from urn:com.sapportals.portal:childToParents, use the following syntax:

...

...

...

...

  1.  In the parent window, subscribe to an event in the different namespace:

EPCM.subscribe(“MyNewNamespace”, “RefreshInbox”, eventHandler);

  2.  In the child window, raise the event:

EPCM.raiseEvent("urn:com.sapportals.portal:childToParents", "MyNewNamespace&RefreshInbox");

Note

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.

 

Was this page helpful to you?