Class sap.m.TokenizerModule: sap/m/Tokenizer

extends Control

Tokenizer displays multiple tokens

Constructor Summary
new sap.m.Tokenizer(sId?, mSettings?)Constructor for a new Tokenizer.
Event Summary
tokenChange(oControlEvent)fired when the tokens aggregation changed (add / remove token)
Events borrowed from class sap.ui.core.Control
Method Summary
sap.m.Tokenizer.extend(sClassName, oClassInfo?, FNMetaImpl?)Creates a new subclass of class sap.m.Tokenizer with name sClassName and enriches it with the information contained in oClassInfo.
sap.m.Tokenizer.getMetadata()Returns a metadata object for class sap.m.Tokenizer.
addAriaDescribedBy(vAriaDescribedBy)Adds some ariaDescribedBy into the association ariaDescribedBy.
addAriaLabelledBy(vAriaLabelledBy)Adds some ariaLabelledBy into the association ariaLabelledBy.
addToken(oToken)Adds some token to the aggregation tokens.
addValidateToken(oParameters)Function validates the given text and adds a new token if validation was successful
addValidator(fValidator)Function adds an validation callback called before any new token gets added to the tokens aggregation
attachTokenChange(oData?, fnFunction, oListener?)Attaches event handler fnFunction to the tokenChange event of this sap.m.Tokenizer.
destroyTokens()Destroys all the tokens in the aggregation tokens.
detachTokenChange(fnFunction, oListener)Detaches event handler fnFunction from the tokenChange event of this sap.m.Tokenizer.
fireTokenChange(mArguments?)Fires event tokenChange to attached listeners.
getAriaDescribedBy()Returns array of IDs of the elements which are the current targets of the association ariaDescribedBy.
getAriaLabelledBy()Returns array of IDs of the elements which are the current targets of the association ariaLabelledBy.
getEditable()Gets current value of property editable.
getScrollDelegate()Function returns the internally used scroll delegate
getScrollWidth()Function returns the tokens' width
getSelectedTokens()Function returns all currently selected tokens
getTokens()Gets content of aggregation tokens.
getWidth()Gets current value of property width.
indexOfToken(oToken)Checks for the provided sap.m.Token in the aggregation tokens.
insertToken(oToken, iIndex)Inserts a token into the aggregation tokens.
removeAllAriaDescribedBy()Removes all the controls in the association named ariaDescribedBy.
removeAllAriaLabelledBy()Removes all the controls in the association named ariaLabelledBy.
removeAllTokens()Removes all the controls from the aggregation tokens.
removeAllValidators()Function removes all validation callbacks
removeAriaDescribedBy(vAriaDescribedBy)Removes an ariaDescribedBy from the association named ariaDescribedBy.
removeAriaLabelledBy(vAriaLabelledBy)Removes an ariaLabelledBy from the association named ariaLabelledBy.
removeSelectedTokens()Function removes all selected tokens
removeToken(vToken)Removes a token from the aggregation tokens.
removeValidator(fValidator)Function removes an validation callback
scrollToEnd(bInitialize)Function scrolls the tokens to the end
scrollToStart()Function scrolls the tokens to the start
selectAllTokens(optional?)Function selects all tokens
setEditable(bEditable)Sets a new value for property editable.
setPixelWidth(nWidth)Function sets the tokenizer's width in pixels
setWidth(sWidth)Sets a new value for property width.
Constructor Detail
new sap.m.Tokenizer(sId?, mSettings?)
Constructor for a new Tokenizer.

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

The supported settings are:

  • Properties
  • Aggregations
    • tokens : sap.m.Token[] (default)
  • Events
    • tokenChange : fnListenerFunction or [fnListenerFunction, oListenerObject] or [oData, fnListenerFunction, oListenerObject]

In addition, all settings applicable to the base type sap.ui.core.Control can be used as well.

Parameters:
{string}sId? id for the new control, generated automatically if no id is given
{object}mSettings? initial settings for the new control
Event Detail
tokenChange(oControlEvent)
fired when the tokens aggregation changed (add / remove token)
Parameters:
{sap.ui.base.Event}oControlEvent
{sap.ui.base.EventProvider}oControlEvent.getSource
{object}oControlEvent.getParameters
{string}oControlEvent.getParameters.type type of tokenChange event. There are four TokenChange types: "added", "removed", "removedAll", "tokensChanged". Use Tokenizer.TokenChangeType.Added for "added", Tokenizer.TokenChangeType.Removed for "removed", Tokenizer.TokenChangeType.RemovedAll for "removedAll" and Tokenizer.TokenChangeType.TokensChanged for "tokensChanged".
{sap.m.Token}oControlEvent.getParameters.token the added token or removed token. This parameter is used when tokenChange type is "added" or "removed".
{sap.m.Token[]}oControlEvent.getParameters.tokens the array of removed tokens. This parameter is used when tokenChange type is "removedAll".
{sap.m.Token[]}oControlEvent.getParameters.addedTokens the array of tokens that are added. This parameter is used when tokenChange type is "tokenChanged".
{sap.m.Token[]}oControlEvent.getParameters.removedTokens the array of tokens that are removed. This parameter is used when tokenChange type is "tokenChanged".
Method Detail
sap.m.Tokenizer.extend(sClassName, oClassInfo?, FNMetaImpl?): function
Creates a new subclass of class sap.m.Tokenizer 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.Control.extend.

Parameters:
{string}sClassName Name of the class being created
{object}oClassInfo? Object literal with information about the class
{function}FNMetaImpl? Constructor function for the metadata object; if not given, it defaults to sap.ui.core.ElementMetadata
Returns:
{function} Created class / constructor function
sap.m.Tokenizer.getMetadata(): sap.ui.base.Metadata
Returns a metadata object for class sap.m.Tokenizer.
Returns:
{sap.ui.base.Metadata} Metadata object describing this class
addAriaDescribedBy(vAriaDescribedBy): sap.m.Tokenizer
Adds some ariaDescribedBy into the association ariaDescribedBy.
Parameters:
{string|sap.ui.core.Control}vAriaDescribedBy the ariaDescribedBy to add; if empty, nothing is inserted
Returns:
{sap.m.Tokenizer} Reference to this in order to allow method chaining
addAriaLabelledBy(vAriaLabelledBy): sap.m.Tokenizer
Adds some ariaLabelledBy into the association ariaLabelledBy.
Parameters:
{string|sap.ui.core.Control}vAriaLabelledBy the ariaLabelledBy to add; if empty, nothing is inserted
Returns:
{sap.m.Tokenizer} Reference to this in order to allow method chaining
addToken(oToken): sap.m.Tokenizer
Adds some token to the aggregation tokens.
Parameters:
{sap.m.Token}oToken the token to add; if empty, nothing is inserted
Returns:
{sap.m.Tokenizer} Reference to this in order to allow method chaining
addValidateToken(oParameters)
Function validates the given text and adds a new token if validation was successful
Parameters:
{object}oParameters parameter bag containing following fields: {sap.m.String} text - the source text {sap.m.Token} [optional] token - a suggested token {object} [optional] suggestionObject - any object used to find the suggested token {function} [optional] validationCallback - callback which gets called after validation has finished
addValidator(fValidator)
Function adds an validation callback called before any new token gets added to the tokens aggregation
Parameters:
{function}fValidator
attachTokenChange(oData?, fnFunction, oListener?): sap.m.Tokenizer
Attaches event handler fnFunction to the tokenChange event of this sap.m.Tokenizer.

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.m.Tokenizer itself.

fired when the tokens aggregation changed (add / remove token)

Parameters:
{object}oData? An application-specific payload object that will be passed to the event handler along with the event object when firing the event
{function}fnFunction The function to be called when the event occurs
{object}oListener? Context object to call the event handler with. Defaults to this sap.m.Tokenizer itself
Returns:
{sap.m.Tokenizer} Reference to this in order to allow method chaining
destroyTokens(): sap.m.Tokenizer
Destroys all the tokens in the aggregation tokens.
Returns:
{sap.m.Tokenizer} Reference to this in order to allow method chaining
detachTokenChange(fnFunction, oListener): sap.m.Tokenizer
Detaches event handler fnFunction from the tokenChange event of this sap.m.Tokenizer.

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

Parameters:
{function}fnFunction The function to be called, when the event occurs
{object}oListener Context object on which the given function had to be called
Returns:
{sap.m.Tokenizer} Reference to this in order to allow method chaining
fireTokenChange(mArguments?): sap.m.Tokenizer
Fires event tokenChange to attached listeners.

Expects the following event parameters:

  • type of type stringtype of tokenChange event. There are four TokenChange types: "added", "removed", "removedAll", "tokensChanged". Use Tokenizer.TokenChangeType.Added for "added", Tokenizer.TokenChangeType.Removed for "removed", Tokenizer.TokenChangeType.RemovedAll for "removedAll" and Tokenizer.TokenChangeType.TokensChanged for "tokensChanged".
  • token of type sap.m.Tokenthe added token or removed token. This parameter is used when tokenChange type is "added" or "removed".
  • tokens of type sap.m.Token[]the array of removed tokens. This parameter is used when tokenChange type is "removedAll".
  • addedTokens of type sap.m.Token[]the array of tokens that are added. This parameter is used when tokenChange type is "tokenChanged".
  • removedTokens of type sap.m.Token[]the array of tokens that are removed. This parameter is used when tokenChange type is "tokenChanged".
Parameters:
{Map}mArguments? The arguments to pass along with the event
Returns:
{sap.m.Tokenizer} Reference to this in order to allow method chaining
getAriaDescribedBy(): sap.ui.core.Control[]
Returns array of IDs of the elements which are the current targets of the association ariaDescribedBy.
Returns:
{sap.ui.core.Control[]}
getAriaLabelledBy(): sap.ui.core.Control[]
Returns array of IDs of the elements which are the current targets of the association ariaLabelledBy.
Returns:
{sap.ui.core.Control[]}
getEditable(): boolean
Gets current value of property editable.

true if tokens shall be editable otherwise false

Default value is true.

Returns:
{boolean} Value of property editable
Function returns the internally used scroll delegate
Returns:
{sap.ui.core.delegate.ScrollEnablement}
getScrollWidth()
Function returns the tokens' width
getSelectedTokens(): sap.m.Token[]
Function returns all currently selected tokens
Returns:
{sap.m.Token[]} - array of selected tokens or empty array
getTokens(): sap.m.Token[]
Gets content of aggregation tokens.

the currently displayed tokens

Returns:
{sap.m.Token[]}
getWidth(): sap.ui.core.CSSSize
Gets current value of property width.

Defines the width of the Tokenizer.

Returns:
{sap.ui.core.CSSSize} Value of property width
indexOfToken(oToken): int
Checks for the provided sap.m.Token in the aggregation tokens. and returns its index if found or -1 otherwise.
Parameters:
{sap.m.Token}oToken The token whose index is looked for
Returns:
{int} The index of the provided control in the aggregation if found, or -1 otherwise
insertToken(oToken, iIndex): sap.m.Tokenizer
Inserts a token into the aggregation tokens.
Parameters:
{sap.m.Token}oToken the token to insert; if empty, nothing is inserted
{int}iIndex the 0-based index the token should be inserted at; for a negative value of iIndex, the token is inserted at position 0; for a value greater than the current size of the aggregation, the token is inserted at the last position
Returns:
{sap.m.Tokenizer} Reference to this in order to allow method chaining
removeAllAriaDescribedBy(): sap.ui.core.Control[]
Removes all the controls in the association named ariaDescribedBy.
Returns:
{sap.ui.core.Control[]} An array of the removed elements (might be empty)
removeAllAriaLabelledBy(): sap.ui.core.Control[]
Removes all the controls in the association named ariaLabelledBy.
Returns:
{sap.ui.core.Control[]} An array of the removed elements (might be empty)
removeAllTokens(): sap.m.Token[]
Removes all the controls from the aggregation tokens.

Additionally, it unregisters them from the hosting UIArea.

Returns:
{sap.m.Token[]} An array of the removed elements (might be empty)
removeAllValidators()
Function removes all validation callbacks
removeAriaDescribedBy(vAriaDescribedBy): sap.ui.core.Control
Removes an ariaDescribedBy from the association named ariaDescribedBy.
Parameters:
{int|string|sap.ui.core.Control}vAriaDescribedBy The ariaDescribedByto be removed or its index or ID
Returns:
{sap.ui.core.Control} the removed ariaDescribedBy or null
removeAriaLabelledBy(vAriaLabelledBy): sap.ui.core.Control
Removes an ariaLabelledBy from the association named ariaLabelledBy.
Parameters:
{int|string|sap.ui.core.Control}vAriaLabelledBy The ariaLabelledByto be removed or its index or ID
Returns:
{sap.ui.core.Control} the removed ariaLabelledBy or null
removeSelectedTokens(): sap.m.Tokenizer
Function removes all selected tokens
Returns:
{sap.m.Tokenizer} - this for chaining
removeToken(vToken): sap.m.Token
Removes a token from the aggregation tokens.
Parameters:
{int|string|sap.m.Token}vToken The tokento remove or its index or id
Returns:
{sap.m.Token} The removed token or null
removeValidator(fValidator)
Function removes an validation callback
Parameters:
{function}fValidator
scrollToEnd(bInitialize)
Function scrolls the tokens to the end
Parameters:
{boolean}bInitialize indicates if we should reset the 'scroll-to-end-pending' flag; if true we would reset this flag
scrollToStart()
Function scrolls the tokens to the start
selectAllTokens(optional?): sap.m.Tokenizer
Function selects all tokens
Parameters:
{boolean}optional? bSelect - true for selecting, false for deselecting
Returns:
{sap.m.Tokenizer} - this for chaining
setEditable(bEditable): sap.m.Tokenizer
Sets a new value for property editable.

true if tokens shall be editable otherwise false

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

Default value is true.

Parameters:
{boolean}bEditable New value for property editable
Returns:
{sap.m.Tokenizer} Reference to this in order to allow method chaining
setPixelWidth(nWidth)
Function sets the tokenizer's width in pixels
Parameters:
{number}nWidth the new width in pixels
setWidth(sWidth): sap.m.Tokenizer
Sets a new value for property width.

Defines the width of the Tokenizer.

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

Parameters:
{sap.ui.core.CSSSize}sWidth New value for property width
Returns:
{sap.m.Tokenizer} Reference to this in order to allow method chaining