Tokens are small items of information (similar to tags) that mainly serve to visualize previously selected items. Tokens are manipulated by a Tokenizer.
The tokens store single text items or sometimes key-value pairs, such as "John Miller (ID1234567)". Each token also contains a delete icon, which is invisible if the token is in edit mode.
Tokens can only be used with the Tokenizer as a container.
Constructor for a new Token.
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.m.Token(sId?, mSettings?)
Param | Type | Default Value | Description |
---|---|---|---|
sId? | string | ID for the new control, generated automatically if no ID is given |
|
mSettings? | object | Initial settings for the new control |
Name | Type | Default Value | Description |
---|---|---|---|
editable | boolean | true | Indicates the editable status of the token. If it is set to |
editableParent | boolean | true | Indicates the editable status of the token's parent (Tokenizer). If it is set to |
key | string | empty string | Key of the token. Visibility: public |
posinset | int | Indicates the position of a token. Used for aria attributes. Visibility: hidden |
|
selected | boolean | false | Indicates the current selection status of the token. Visibility: public |
setsize | int | Indicates the count of the token. Used for aria attributes. Visibility: hidden |
|
text | string | empty string | Displayed text of the token. Visibility: public |
textDirection | sap.ui.core.TextDirection | Inherit | This property specifies the text directionality with enumerated options. By default, the control inherits text direction from the DOM. |
truncated | boolean | false | Indicates if the token's text should be truncated. Visibility: hidden |
Default Aggregation:
Name | Cardinality | Type | Description |
---|---|---|---|
deleteIcon | 0..1 | sap.ui.core.Icon |
The delete icon. |
Name | Cardinality | Type | Description |
---|---|---|---|
ariaDescribedBy | 0..n | sap.ui.core.Control |
Association to controls / IDs which describe this control (see WAI-ARIA attribute aria-describedby). |
ariaLabelledBy | 0..n | sap.ui.core.Control |
Association to controls / IDs which label this control (see WAI-ARIA attribute aria-labelledby). |
Event | Description |
---|---|
delete |
This event is fired if the user clicks the token's delete icon. This event bubbles up the control hierarchy. |
deselect |
This event is fired when the token gets deselected. |
press |
This event is fired when the user clicks on the token. |
select |
This event is fired when the token gets selected. |
This event is fired if the user clicks the token's delete icon.
This event bubbles up the control hierarchy.
Param | Type | Description |
---|---|---|
oControlEvent | sap.ui.base.Event | |
getSource | sap.ui.base.EventProvider | |
getParameters | object |
This event is fired when the token gets deselected.
Param | Type | Description |
---|---|---|
oControlEvent | sap.ui.base.Event | |
getSource | sap.ui.base.EventProvider | |
getParameters | object |
Method | Description |
---|---|
addAriaDescribedBy |
Adds some ariaDescribedBy into the association ariaDescribedBy. |
addAriaLabelledBy |
Adds some ariaLabelledBy into the association ariaLabelledBy. |
attachDelete |
Attaches event handler When called, the context of the event handler (its This event is fired if the user clicks the token's delete icon. |
attachDeselect |
Attaches event handler When called, the context of the event handler (its This event is fired when the token gets deselected. |
attachPress |
Attaches event handler When called, the context of the event handler (its This event is fired when the user clicks on the token. |
attachSelect |
Attaches event handler When called, the context of the event handler (its This event is fired when the token gets selected. |
detachDelete |
Detaches event handler The passed function and listener object must match the ones used for event registration. |
detachDeselect |
Detaches event handler The passed function and listener object must match the ones used for event registration. |
detachPress |
Detaches event handler The passed function and listener object must match the ones used for event registration. |
detachSelect |
Detaches event handler The passed function and listener object must match the ones used for event registration. |
sap.m.Token.extend |
Creates a new subclass of class sap.m.Token with name
|
fireDelete |
Fires event delete to attached listeners. |
fireDeselect |
Fires event deselect to attached listeners. |
firePress |
Fires event press to attached listeners. |
fireSelect |
Fires event select 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. Indicates the editable status of the token. If it is set to Default value is |
getKey |
Gets current value of property key. Key of the token. Default value is |
sap.m.Token.getMetadata |
Returns a metadata object for class sap.m.Token. |
getSelected |
Gets current value of property selected. Indicates the current selection status of the token. Default value is |
getText |
Gets current value of property text. Displayed text of the token. Default value is |
getTextDirection |
Gets current value of property textDirection. This property specifies the text directionality with enumerated options. By default, the control inherits text direction from the DOM. Default value is |
getTruncated |
Returns the value of Token's |
removeAllAriaDescribedBy |
Removes all the controls in the association named ariaDescribedBy. |
removeAllAriaLabelledBy |
Removes all the controls in the association named ariaLabelledBy. |
removeAriaDescribedBy |
Removes an ariaDescribedBy from the association named ariaDescribedBy. |
removeAriaLabelledBy |
Removes an ariaLabelledBy from the association named ariaLabelledBy. |
setEditable |
Sets a new value for property editable. Indicates the editable status of the token. If it is set to When called with a value of Default value is |
setKey |
Sets a new value for property key. Key of the token. When called with a value of Default value is |
setSelected |
Sets a new value for property selected. Indicates the current selection status of the token. When called with a value of Default value is |
setText |
Sets a new value for property text. Displayed text of the token. When called with a value of Default value is |
setTextDirection |
Sets a new value for property textDirection. This property specifies the text directionality with enumerated options. By default, the control inherits text direction from the DOM. When called with a value of Default value is |
setTruncated |
Sets the Token's |
Adds some ariaDescribedBy into the association ariaDescribedBy.
Param | Type | DefaultValue | Description |
---|---|---|---|
vAriaDescribedBy | sap.ui.core.ID sap.ui.core.Control |
The ariaDescribedBy to add; if empty, nothing is inserted |
Adds some ariaLabelledBy into the association ariaLabelledBy.
Param | Type | DefaultValue | Description |
---|---|---|---|
vAriaLabelledBy | sap.ui.core.ID sap.ui.core.Control |
The ariaLabelledBy to add; if empty, nothing is inserted |
Attaches event handler fnFunction
to the delete event of this sap.m.Token
.
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.Token
itself.
This event is fired if the user clicks the token's delete icon.
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 |
Attaches event handler fnFunction
to the deselect event of this sap.m.Token
.
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.Token
itself.
This event is fired when the token gets deselected.
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 |
Attaches event handler fnFunction
to the press event of this sap.m.Token
.
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.Token
itself.
This event is fired when the user clicks on the token.
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 |
Attaches event handler fnFunction
to the select event of this sap.m.Token
.
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.Token
itself.
This event is fired when the token gets selected.
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 |
Detaches event handler fnFunction
from the delete event of this sap.m.Token
.
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 |
Detaches event handler fnFunction
from the deselect event of this sap.m.Token
.
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 |
Detaches event handler fnFunction
from the press event of this sap.m.Token
.
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 |
Detaches event handler fnFunction
from the select event of this sap.m.Token
.
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 |
Creates a new subclass of class sap.m.Token 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.
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 |
Fires event delete to attached listeners.
Param | Type | DefaultValue | Description |
---|---|---|---|
mParameters | object |
Parameters to pass along with the event |
Fires event deselect to attached listeners.
Param | Type | DefaultValue | Description |
---|---|---|---|
mParameters | object |
Parameters to pass along with the event |
Fires event press to attached listeners.
Param | Type | DefaultValue | Description |
---|---|---|---|
mParameters | object |
Parameters to pass along with the event |
Fires event select to attached listeners.
Param | Type | DefaultValue | Description |
---|---|---|---|
mParameters | object |
Parameters to pass along with the event |
Returns array of IDs of the elements which are the current targets of the association ariaDescribedBy.
Returns array of IDs of the elements which are the current targets of the association ariaLabelledBy.
Gets current value of property editable.
Indicates the editable status of the token. If it is set to true
, token displays a delete icon.
Default value is true
.
Gets current value of property selected.
Indicates the current selection status of the token.
Default value is false
.
Gets current value of property text.
Displayed text of the token.
Default value is empty string
.
Gets current value of property textDirection.
This property specifies the text directionality with enumerated options. By default, the control inherits text direction from the DOM.
Default value is Inherit
.
Removes an ariaDescribedBy from the association named ariaDescribedBy.
Param | Type | DefaultValue | Description |
---|---|---|---|
vAriaDescribedBy | int sap.ui.core.ID sap.ui.core.Control |
The ariaDescribedBy to be removed or its index or ID |
Removes an ariaLabelledBy from the association named ariaLabelledBy.
Param | Type | DefaultValue | Description |
---|---|---|---|
vAriaLabelledBy | int sap.ui.core.ID sap.ui.core.Control |
The ariaLabelledBy to be removed or its index or ID |
Sets a new value for property editable.
Indicates the editable status of the token. If it is set to true
, token displays a delete icon.
When called with a value of null
or undefined
, the default value of the property will be restored.
Default value is true
.
Param | Type | DefaultValue | Description |
---|---|---|---|
bEditable | boolean | true |
New value for property |
Sets a new value for property key.
Key of the token.
When called with a value of null
or undefined
, the default value of the property will be restored.
Default value is empty string
.
Param | Type | DefaultValue | Description |
---|---|---|---|
sKey | string | "" |
New value for property |
Sets a new value for property selected.
Indicates the current selection status of the token.
When called with a value of null
or undefined
, the default value of the property will be restored.
Default value is false
.
Param | Type | DefaultValue | Description |
---|---|---|---|
bSelected | boolean | false |
New value for property |
Sets a new value for property text.
Displayed text of the token.
When called with a value of null
or undefined
, the default value of the property will be restored.
Default value is empty string
.
Param | Type | DefaultValue | Description |
---|---|---|---|
sText | string | "" |
New value for property |
Sets a new value for property textDirection.
This property specifies the text directionality with enumerated options. By default, the control inherits text direction from the DOM.
When called with a value of null
or undefined
, the default value of the property will be restored.
Default value is Inherit
.
Param | Type | DefaultValue | Description |
---|---|---|---|
sTextDirection | sap.ui.core.TextDirection | Inherit |
New value for property |