class sap.ui.integration.Host

Control sample: sap.ui.integration.Host
Visiblity: public
UX Guidelines:
Implements:
Available since: N/A
Module: sap/ui/integration/Host
Application Component: CA-UI5-CTR

Provides application-level functions and services to an integration card.

Examples may include, but are not limited to options like: share a card, remove a card.


Constructor

Constructor for a new Host.

Accepts an object literal mSettings that defines initial property values, aggregated and associated objects as well as event handlers. See sap.ui.base.ManagedObject#constructor for a general description of the syntax of the settings object.

new sap.ui.integration.Host(sId?, mSettings?)
Param Type Default Value Description
sId? string

ID for the new host, generated automatically if no ID is given.

mSettings? object

Initial settings for the new host.


Properties

Name Type Default Value Description
actions sap.ui.integration.CardMenuAction[]

The actions configuration.

Visibility: public
resolveDestination function

A function that resolves the given destination name to a URL.

The Card calls this function when it needs to send a request to a destination. Function returns the URL to which the request is sent.

If a card depends on a destination, but this callback is not implemented, an error will be logged.

The callback receives destinationName as parameter and returns a string with the URL. Or alternatively the callback may return a Promise with the URL as an argument.

Visibility: public

Events Overview

Event Description
action

Fired when an action is triggered.

Listeners may prevent the default action of this event by calling the preventDefault method on the event object.

cardConfigurationChange

Fired when some card configuration settings are changed as a result of user interaction. For example - filter value is changed.

message

Fired when a message from channels like navigator.serviceWorker is received.

action

Fired when an action is triggered.

Listeners may prevent the default action of this event by calling the preventDefault method on the event object.

Param Type Description
oControlEvent sap.ui.base.Event
getSource sap.ui.base.EventProvider
getParameters object
card sap.ui.core.Control

The card the action is fired from.

actionConfig object

The action configuration.

actionSource sap.ui.core.Control

The action source.

parameters object

The parameters related to the triggered action.

type sap.ui.integration.CardActionType

The type of the action.

cardConfigurationChange

Fired when some card configuration settings are changed as a result of user interaction. For example - filter value is changed.

Param Type Description
oControlEvent sap.ui.base.Event
getSource sap.ui.base.EventProvider
getParameters object
card sap.ui.core.Control

The card the changes are fired from.

changes object

Changed configuration settings.

Example:

 {
 	"/sap.card/configuration/filters/shipper/value": "key3",
 	"/sap.card/configuration/filters/item/value": "key2"
 }

message

Fired when a message from channels like navigator.serviceWorker is received.

Param Type Description
oControlEvent sap.ui.base.Event
getSource sap.ui.base.EventProvider
getParameters object
data object

Methods Overview

Method Description
attachAction

Attaches event handler fnFunction to the action event of this sap.ui.integration.Host.

When called, the context of the event handler (its this) will be bound to oListener if specified, otherwise it will be bound to this sap.ui.integration.Host itself.

Fired when an action is triggered.

attachCardConfigurationChange

Attaches event handler fnFunction to the cardConfigurationChange event of this sap.ui.integration.Host.

When called, the context of the event handler (its this) will be bound to oListener if specified, otherwise it will be bound to this sap.ui.integration.Host itself.

Fired when some card configuration settings are changed as a result of user interaction. For example - filter value is changed.

attachMessage

Attaches event handler fnFunction to the message event of this sap.ui.integration.Host.

When called, the context of the event handler (its this) will be bound to oListener if specified, otherwise it will be bound to this sap.ui.integration.Host itself.

Fired when a message from channels like navigator.serviceWorker is received.

detachAction

Detaches event handler fnFunction from the action event of this sap.ui.integration.Host.

The passed function and listener object must match the ones used for event registration.

detachCardConfigurationChange

Detaches event handler fnFunction from the cardConfigurationChange event of this sap.ui.integration.Host.

The passed function and listener object must match the ones used for event registration.

detachMessage

Detaches event handler fnFunction from the message event of this sap.ui.integration.Host.

The passed function and listener object must match the ones used for event registration.

sap.ui.integration.Host.extend

Creates a new subclass of class sap.ui.integration.Host 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.core.Element.extend.

fireAction

Fires event action to attached listeners.

Listeners may prevent the default action of this event by calling the preventDefault method on the event object. The return value of this method indicates whether the default action should be executed.

fireCardConfigurationChange

Fires event cardConfigurationChange to attached listeners.

fireMessage

Fires event message to attached listeners.

getActions

Gets current value of property actions.

The actions configuration.

getContexts

Returns the context object for the Card Editor design-time environment Contexts can be used to configure Cards with information available in the host environment. Each entry in the list should contain design-time information. A label, placeholder, and description should be provided.

Example Context Structure: { "sap.workzone": { "currentUser: { "id": { "label": "Id of the Work Zone user", "placeholder": "Work Zone user id", "description": "The value will change based on the logged on user" } } } ... }

The context information and texts should be translated as they appear in the design-time UI of the Card Editor.

getContextValue

Resolves the value for a given path in the context of the host Contexts can be used to configure Cards with information available in the host environment.

Example Context Structure: { "sap.workzone": { "currentUser: { "id": { "label": "Id of the Work Zone user", "placeholder": "Work Zone user id", "description": "The value will change based on the logged on user" } } } ... }

Example path to the current user id of the context sPath = "sap.workzone/currentUser/id" parameter: { userId: { value: "{context>sap.workzone/currentUser/id}" resolves to UserId } }

getDestination

Resolves the destination and returns its URL.

getDestinations

Returns the list of destinations for the Card Editor design-time environment List entries are objects that contain at least the name. { "name": "DestinationName" }

sap.ui.integration.Host.getMetadata

Returns a metadata object for class sap.ui.integration.Host.

getResolveDestination

Gets current value of property resolveDestination.

A function that resolves the given destination name to a URL.

The Card calls this function when it needs to send a request to a destination. Function returns the URL to which the request is sent.

If a card depends on a destination, but this callback is not implemented, an error will be logged.

The callback receives destinationName as parameter and returns a string with the URL. Or alternatively the callback may return a Promise with the URL as an argument.

modifyRequestHeaders

Modify request headers before sending a data request. Override if you need to change the default cache headers behavior.

setActions

Sets a new value for property actions.

The actions configuration.

When called with a value of null or undefined, the default value of the property will be restored.

setResolveDestination

Sets a new value for property resolveDestination.

A function that resolves the given destination name to a URL.

The Card calls this function when it needs to send a request to a destination. Function returns the URL to which the request is sent.

If a card depends on a destination, but this callback is not implemented, an error will be logged.

The callback receives destinationName as parameter and returns a string with the URL. Or alternatively the callback may return a Promise with the URL as an argument.

When called with a value of null or undefined, the default value of the property will be restored.

stopUsingExperimentalCaching

Stops the usage of the experimental caching for all cards.

subscribeForMessages

By default subscribes to navigator.serviceWorker messages. Override to subscribe to different channels.

unsubscribeForMessages

Unsubscribes from navigator.serviceWorker messages.

useExperimentalCaching

Call this method if you want to use the experimental caching for all cards.

attachAction

Attaches event handler fnFunction to the action event of this sap.ui.integration.Host.

When called, the context of the event handler (its this) will be bound to oListener if specified, otherwise it will be bound to this sap.ui.integration.Host itself.

Fired when an action is triggered.

Param Type DefaultValue Description
oData object

An application-specific payload object that will be passed to the event handler along with the event object when firing the event

fnFunction function(sap.ui.base.Event) : void

The function to be called when the event occurs

oListener object

Context object to call the event handler with. Defaults to this sap.ui.integration.Host itself

attachCardConfigurationChange

Attaches event handler fnFunction to the cardConfigurationChange event of this sap.ui.integration.Host.

When called, the context of the event handler (its this) will be bound to oListener if specified, otherwise it will be bound to this sap.ui.integration.Host itself.

Fired when some card configuration settings are changed as a result of user interaction. For example - filter value is changed.

Param Type DefaultValue Description
oData object

An application-specific payload object that will be passed to the event handler along with the event object when firing the event

fnFunction function(sap.ui.base.Event) : void

The function to be called when the event occurs

oListener object

Context object to call the event handler with. Defaults to this sap.ui.integration.Host itself

attachMessage

Attaches event handler fnFunction to the message event of this sap.ui.integration.Host.

When called, the context of the event handler (its this) will be bound to oListener if specified, otherwise it will be bound to this sap.ui.integration.Host itself.

Fired when a message from channels like navigator.serviceWorker is received.

Param Type DefaultValue Description
oData object

An application-specific payload object that will be passed to the event handler along with the event object when firing the event

fnFunction function(sap.ui.base.Event) : void

The function to be called when the event occurs

oListener object

Context object to call the event handler with. Defaults to this sap.ui.integration.Host itself

detachAction

Detaches event handler fnFunction from the action event of this sap.ui.integration.Host.

The passed function and listener object must match the ones used for event registration.

Param Type DefaultValue Description
fnFunction function(sap.ui.base.Event) : void

The function to be called, when the event occurs

oListener object

Context object on which the given function had to be called

detachCardConfigurationChange

Detaches event handler fnFunction from the cardConfigurationChange event of this sap.ui.integration.Host.

The passed function and listener object must match the ones used for event registration.

Param Type DefaultValue Description
fnFunction function(sap.ui.base.Event) : void

The function to be called, when the event occurs

oListener object

Context object on which the given function had to be called

detachMessage

Detaches event handler fnFunction from the message event of this sap.ui.integration.Host.

The passed function and listener object must match the ones used for event registration.

Param Type DefaultValue Description
fnFunction function(sap.ui.base.Event) : void

The function to be called, when the event occurs

oListener object

Context object on which the given function had to be called

sap.ui.integration.Host.extend

Creates a new subclass of class sap.ui.integration.Host 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.core.Element.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

fireAction

Fires event action to attached listeners.

Listeners may prevent the default action of this event by calling the preventDefault method on the event object. The return value of this method indicates whether the default action should be executed.

Param Type DefaultValue Description
mParameters object

Parameters to pass along with the event

card sap.ui.core.Control

The card the action is fired from.

actionConfig object

The action configuration.

actionSource sap.ui.core.Control

The action source.

parameters object

The parameters related to the triggered action.

type sap.ui.integration.CardActionType

The type of the action.

fireCardConfigurationChange

Fires event cardConfigurationChange to attached listeners.

Param Type DefaultValue Description
mParameters object

Parameters to pass along with the event

card sap.ui.core.Control

The card the changes are fired from.

changes object

Changed configuration settings.

Example:

 {
 	"/sap.card/configuration/filters/shipper/value": "key3",
 	"/sap.card/configuration/filters/item/value": "key2"
 }

fireMessage

Fires event message to attached listeners.

Param Type DefaultValue Description
mParameters object

Parameters to pass along with the event

data object

getActions

Gets current value of property actions.

The actions configuration.

getContexts

Returns the context object for the Card Editor design-time environment Contexts can be used to configure Cards with information available in the host environment. Each entry in the list should contain design-time information. A label, placeholder, and description should be provided.

Example Context Structure: { "sap.workzone": { "currentUser: { "id": { "label": "Id of the Work Zone user", "placeholder": "Work Zone user id", "description": "The value will change based on the logged on user" } } } ... }

The context information and texts should be translated as they appear in the design-time UI of the Card Editor.

getContextValue

Resolves the value for a given path in the context of the host Contexts can be used to configure Cards with information available in the host environment.

Example Context Structure: { "sap.workzone": { "currentUser: { "id": { "label": "Id of the Work Zone user", "placeholder": "Work Zone user id", "description": "The value will change based on the logged on user" } } } ... }

Example path to the current user id of the context sPath = "sap.workzone/currentUser/id" parameter: { userId: { value: "{context>sap.workzone/currentUser/id}" resolves to UserId } }

Param Type DefaultValue Description
sPath string

The path to a context

getDestination

Resolves the destination and returns its URL.

Param Type DefaultValue Description
sDestinationName string

The name of the destination. Most often the name which is used in the SAP Cloud Platform.

getDestinations

Returns the list of destinations for the Card Editor design-time environment List entries are objects that contain at least the name. { "name": "DestinationName" }

sap.ui.integration.Host.getMetadata

Returns a metadata object for class sap.ui.integration.Host.

getResolveDestination

Gets current value of property resolveDestination.

A function that resolves the given destination name to a URL.

The Card calls this function when it needs to send a request to a destination. Function returns the URL to which the request is sent.

If a card depends on a destination, but this callback is not implemented, an error will be logged.

The callback receives destinationName as parameter and returns a string with the URL. Or alternatively the callback may return a Promise with the URL as an argument.

modifyRequestHeaders

Modify request headers before sending a data request. Override if you need to change the default cache headers behavior.

Param Type DefaultValue Description
mHeaders Object<string,any>

The current map of headers.

mSettings Object<string,any>

The map of request settings defined in the card manifest.

oCard sap.ui.integration.widgets.Card

The card for which the request is made.

setActions

Sets a new value for property actions.

The actions configuration.

When called with a value of null or undefined, the default value of the property will be restored.

Param Type DefaultValue Description
sActions sap.ui.integration.CardMenuAction[]

New value for property actions

setResolveDestination

Sets a new value for property resolveDestination.

A function that resolves the given destination name to a URL.

The Card calls this function when it needs to send a request to a destination. Function returns the URL to which the request is sent.

If a card depends on a destination, but this callback is not implemented, an error will be logged.

The callback receives destinationName as parameter and returns a string with the URL. Or alternatively the callback may return a Promise with the URL as an argument.

When called with a value of null or undefined, the default value of the property will be restored.

Param Type DefaultValue Description
fnResolveDestination function

New value for property resolveDestination

stopUsingExperimentalCaching

Stops the usage of the experimental caching for all cards.

subscribeForMessages

By default subscribes to navigator.serviceWorker messages. Override to subscribe to different channels.

unsubscribeForMessages

Unsubscribes from navigator.serviceWorker messages.

useExperimentalCaching

Call this method if you want to use the experimental caching for all cards.