abstract class sap.ui.base.EventProvider

Control sample: sap.ui.base.EventProvider
Visiblity: public
UX Guidelines:
Implements:
Available since: N/A
Module: sap/ui/base/EventProvider
Application Component: CA-UI5-COR

Provides eventing capabilities for objects like attaching or detaching event handlers for events which are notified when events are fired.


Constructor

Creates an instance of EventProvider.

new sap.ui.base.EventProvider()

Methods Overview

Method Description
attachEvent

Attaches an event handler to the event with the given identifier.

attachEventOnce

Attaches an event handler, called one time only, to the event with the given identifier.

When the event occurs, the handler function is called and the handler registration is automatically removed afterwards.

destroy

Cleans up the internal structures and removes all event handlers.

The object must not be used anymore after destroy was called.

References:

  • sap.ui.base.Object#destroy

detachEvent

Removes a previously attached event handler from the event with the given identifier.

The passed parameters must match those used for registration with #attachEvent beforehand.

sap.ui.base.EventProvider.extend

Creates a new subclass of class sap.ui.base.EventProvider with name sClassName and enriches it with the information contained in oClassInfo.

oClassInfo might contain the same kind of information as described in sap.ui.base.Object.extend.

fireEvent

Fires an event with the given settings and notifies all attached event handlers.

getEventingParent

Returns the parent in the eventing hierarchy of this object.

Per default this returns null, but if eventing is used in objects, which are hierarchically structured, this can be overwritten to make the object hierarchy visible to the eventing and enables the use of event bubbling within this object hierarchy.

sap.ui.base.EventProvider.getMetadata

Returns a metadata object for class sap.ui.base.EventProvider.

sap.ui.base.EventProvider.hasListener

Checks whether the given event provider has the given listener registered for the given event.

Returns true if function and listener object both match the corresponding parameters of at least one listener registered for the named event.

hasListeners

Returns whether there are any registered event handlers for the event with the given identifier.

toString

Returns a string representation of this object.

In case there is no class or id information, a simple static string is returned. Subclasses should override this method.

attachEvent

Attaches an event handler to the event with the given identifier.

Param Type DefaultValue Description
sEventId string

The identifier of the event to listen for

oData object

An object that will be passed to the handler along with the event object when the event is fired

fnFunction function

The handler function to call when the event occurs. This function will be called in the context of the oListener instance (if present) or on the event provider instance. The event object (sap.ui.base.Event) is provided as first argument of the handler. Handlers must not change the content of the event. The second argument is the specified oData instance (if present).

oListener object

The object that wants to be notified when the event occurs (this context within the handler function). If it is not specified, the handler function is called in the context of the event provider.

attachEventOnce

Attaches an event handler, called one time only, to the event with the given identifier.

When the event occurs, the handler function is called and the handler registration is automatically removed afterwards.

Param Type DefaultValue Description
sEventId string

The identifier of the event to listen for

oData object

An object that will be passed to the handler along with the event object when the event is fired

fnFunction function

The handler function to call when the event occurs. This function will be called in the context of the oListener instance (if present) or on the event provider instance. The event object (sap.ui.base.Event) is provided as first argument of the handler. Handlers must not change the content of the event. The second argument is the specified oData instance (if present).

oListener object

The object that wants to be notified when the event occurs (this context within the handler function). If it is not specified, the handler function is called in the context of the event provider.

destroy

Cleans up the internal structures and removes all event handlers.

The object must not be used anymore after destroy was called.

References:

detachEvent

Removes a previously attached event handler from the event with the given identifier.

The passed parameters must match those used for registration with #attachEvent beforehand.

Param Type DefaultValue Description
sEventId string

The identifier of the event to detach from

fnFunction function

The handler function to detach from the event

oListener object

The object that wanted to be notified when the event occurred

sap.ui.base.EventProvider.extend

Creates a new subclass of class sap.ui.base.EventProvider with name sClassName and enriches it with the information contained in oClassInfo.

oClassInfo might contain the same kind of information as described in sap.ui.base.Object.extend.

Param Type DefaultValue Description
sClassName string

Name of the class being created

oClassInfo object

Object literal with information about the class

FNMetaImpl function

Constructor function for the metadata object; if not given, it defaults to the metadata implementation used by this class

fireEvent

Fires an event with the given settings and notifies all attached event handlers.

Param Type DefaultValue Description
sEventId string

The identifier of the event to fire

oParameters object

Parameters which should be carried by the event

bAllowPreventDefault boolean

Defines whether function preventDefault is supported on the fired event

bEnableEventBubbling boolean

Defines whether event bubbling is enabled on the fired event. Set to true the event is also forwarded to the parent(s) of the event provider (#getEventingParent) until the bubbling of the event is stopped or no parent is available anymore.

getEventingParent

Returns the parent in the eventing hierarchy of this object.

Per default this returns null, but if eventing is used in objects, which are hierarchically structured, this can be overwritten to make the object hierarchy visible to the eventing and enables the use of event bubbling within this object hierarchy.

sap.ui.base.EventProvider.getMetadata

Returns a metadata object for class sap.ui.base.EventProvider.

sap.ui.base.EventProvider.hasListener

Checks whether the given event provider has the given listener registered for the given event.

Returns true if function and listener object both match the corresponding parameters of at least one listener registered for the named event.

Param Type DefaultValue Description
oEventProvider sap.ui.base.EventProvider

The event provider to get the registered events for

sEventId string

The identifier of the event to check listeners for

fnFunction function

The handler function to check for

oListener object

The listener object to check for

hasListeners

Returns whether there are any registered event handlers for the event with the given identifier.

Param Type DefaultValue Description
sEventId string

The identifier of the event

toString

Returns a string representation of this object.

In case there is no class or id information, a simple static string is returned. Subclasses should override this method.