Class sap.m.LinkModule: sap/m/Link

extends Control
implements IShrinkable
known direct subclasses: SmartLink

A hyperlink control which can be used to trigger actions or to navigate to other applications or web pages.


Since: 1.12.
Constructor Summary
new sap.m.Link(sId?, mSettings?)Constructor for a new Link.
Event Summary
press(oControlEvent)Event is fired when the user triggers the link control.
Events borrowed from class sap.ui.core.Control
Method Summary
sap.m.Link.extend(sClassName, oClassInfo?, FNMetaImpl?)Creates a new subclass of class sap.m.Link with name sClassName and enriches it with the information contained in oClassInfo.
sap.m.Link.getMetadata()Returns a metadata object for class sap.m.Link.
addAriaDescribedBy(vAriaDescribedBy)Adds some ariaDescribedBy into the association ariaDescribedBy.
addAriaLabelledBy(vAriaLabelledBy)Adds some ariaLabelledBy into the association ariaLabelledBy.
attachPress(oData?, fnFunction, oListener?)Attaches event handler fnFunction to the press event of this sap.m.Link.
detachPress(fnFunction, oListener)Detaches event handler fnFunction from the press event of this sap.m.Link.
firePress(mArguments?)Fires event press 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.
getEmphasized()Gets current value of property emphasized.
getEnabled()Gets current value of property enabled.
getHref()Gets current value of property href.
getRel()Gets current value of property rel.
getSubtle()Gets current value of property subtle.
getTarget()Gets current value of property target.
getText()Gets current value of property text.
getTextAlign()Gets current value of property textAlign.
getTextDirection()Gets current value of property textDirection.
getWidth()Gets current value of property width.
getWrapping()Gets current value of property wrapping.
removeAllAriaDescribedBy()Removes all the controls in the association named ariaDescribedBy.
removeAllAriaLabelledBy()Removes all the controls in the association named ariaLabelledBy.
removeAriaDescribedBy(vAriaDescribedBy)Removes an ariaDescribedBy from the association named ariaDescribedBy.
removeAriaLabelledBy(vAriaLabelledBy)Removes an ariaLabelledBy from the association named ariaLabelledBy.
setEmphasized(bEmphasized)Sets a new value for property emphasized.
setEnabled(bEnabled)Sets a new value for property enabled.
setHref(sHref)Sets a new value for property href.
setRel(sRel)Sets a new value for property rel.
setSubtle(bSubtle)Sets a new value for property subtle.
setTarget(sTarget)Sets a new value for property target.
setText(sText)Sets a new value for property text.
setTextAlign(sTextAlign)Sets a new value for property textAlign.
setTextDirection(sTextDirection)Sets a new value for property textDirection.
setWidth(sWidth)Sets a new value for property width.
setWrapping(bWrapping)Sets a new value for property wrapping.
Constructor Detail
new sap.m.Link(sId?, mSettings?)
Constructor for a new Link.

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
  • Events
    • press : 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
press(oControlEvent)
Event is fired when the user triggers the link control.
Parameters:
{sap.ui.base.Event}oControlEvent
{sap.ui.base.EventProvider}oControlEvent.getSource
{object}oControlEvent.getParameters
Method Detail
sap.m.Link.extend(sClassName, oClassInfo?, FNMetaImpl?): function
Creates a new subclass of class sap.m.Link 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.Link.getMetadata(): sap.ui.base.Metadata
Returns a metadata object for class sap.m.Link.
Returns:
{sap.ui.base.Metadata} Metadata object describing this class
addAriaDescribedBy(vAriaDescribedBy): sap.m.Link
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.Link} Reference to this in order to allow method chaining
addAriaLabelledBy(vAriaLabelledBy): sap.m.Link
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.Link} Reference to this in order to allow method chaining
attachPress(oData?, fnFunction, oListener?): sap.m.Link
Attaches event handler fnFunction to the press event of this sap.m.Link.

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.Link itself.

Event is fired when the user triggers the link control.

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.Link itself
Returns:
{sap.m.Link} Reference to this in order to allow method chaining
detachPress(fnFunction, oListener): sap.m.Link
Detaches event handler fnFunction from the press event of this sap.m.Link.

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.Link} Reference to this in order to allow method chaining
firePress(mArguments?): boolean
Fires event press to attached listeners.

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

Parameters:
{Map}mArguments? The arguments to pass along with the event
Returns:
{boolean} Whether or not to prevent the default action
getAccessibilityInfo()
See:
{sap.ui.core.Control#getAccessibilityInfo}
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[]}
getEmphasized(): boolean
Gets current value of property emphasized.

Emphasized links look visually more important than regular links.

Default value is false.

Since:
1.22
Returns:
{boolean} Value of property emphasized
getEnabled(): boolean
Gets current value of property enabled.

Determines whether the link can be triggered by the user.

Default value is true.

Returns:
{boolean} Value of property enabled
getHref(): sap.ui.core.URI
Gets current value of property href.

The link target URI. Supports standard hyperlink behavior. If a JavaScript action should be triggered, this should not be set, but instead an event handler for the "press" event should be registered.

Returns:
{sap.ui.core.URI} Value of property href
getRel(): string
Gets current value of property rel.

Specifies the value of the HTML rel attribute.

Note: A default value of noopener noreferrer is set only to links that have a cross-origin URL and a specified target with value other than _self.

Since:
1.38.49
Returns:
{string} Value of property rel
getSubtle(): boolean
Gets current value of property subtle.

Subtle links look more like standard text than like links. They should only be used to help with visual hierarchy between large data lists of important and less important links. Subtle links should not be used in any other use case.

Default value is false.

Since:
1.22
Returns:
{boolean} Value of property subtle
getTarget(): string
Gets current value of property target.

Options are the standard values for window.open() supported by browsers: _self, _top, _blank, _parent, _search. Alternatively, a frame name can be entered. This property is only used when the href property is set.

Returns:
{string} Value of property target
getText(): string
Gets current value of property text.

Link text to be displayed.

Default value is .

Returns:
{string} Value of property text
getTextAlign(): sap.ui.core.TextAlign
Gets current value of property textAlign.

Sets the horizontal alignment of the text.

Default value is Initial.

Since:
1.28.0
Returns:
{sap.ui.core.TextAlign} Value of property textAlign
getTextDirection(): sap.ui.core.TextDirection
Gets current value of property textDirection.

This property specifies the element's text directionality with enumerated options. By default, the control inherits text direction from the parent DOM.

Default value is Inherit.

Since:
1.28.0
Returns:
{sap.ui.core.TextDirection} Value of property textDirection
getWidth(): sap.ui.core.CSSSize
Gets current value of property width.

Determines the width of the link (CSS-size such as % or px). When it is set, this is the exact size. When left blank, the text defines the size.

Returns:
{sap.ui.core.CSSSize} Value of property width
getWrapping(): boolean
Gets current value of property wrapping.

Determines whether the link text is allowed to wrap when there is not sufficient space.

Default value is false.

Returns:
{boolean} Value of property wrapping
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)
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
setEmphasized(bEmphasized): sap.m.Link
Sets a new value for property emphasized.

Emphasized links look visually more important than regular links.

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

Default value is false.

Parameters:
{boolean}bEmphasized New value for property emphasized
Since:
1.22
Returns:
{sap.m.Link} Reference to this in order to allow method chaining
setEnabled(bEnabled): sap.m.Link
Sets a new value for property enabled.

Determines whether the link can be triggered by the user.

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

Default value is true.

Parameters:
{boolean}bEnabled New value for property enabled
Returns:
{sap.m.Link} Reference to this in order to allow method chaining
setHref(sHref): sap.m.Link
Sets a new value for property href.

The link target URI. Supports standard hyperlink behavior. If a JavaScript action should be triggered, this should not be set, but instead an event handler for the "press" event should be registered.

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

Parameters:
{sap.ui.core.URI}sHref New value for property href
Returns:
{sap.m.Link} Reference to this in order to allow method chaining
setRel(sRel): sap.m.Link
Sets a new value for property rel.

Specifies the value of the HTML rel attribute.

Note: A default value of noopener noreferrer is set only to links that have a cross-origin URL and a specified target with value other than _self.

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

Parameters:
{string}sRel New value for property rel
Since:
1.38.49
Returns:
{sap.m.Link} Reference to this in order to allow method chaining
setSubtle(bSubtle): sap.m.Link
Sets a new value for property subtle.

Subtle links look more like standard text than like links. They should only be used to help with visual hierarchy between large data lists of important and less important links. Subtle links should not be used in any other use case.

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

Default value is false.

Parameters:
{boolean}bSubtle New value for property subtle
Since:
1.22
Returns:
{sap.m.Link} Reference to this in order to allow method chaining
setTarget(sTarget): sap.m.Link
Sets a new value for property target.

Options are the standard values for window.open() supported by browsers: _self, _top, _blank, _parent, _search. Alternatively, a frame name can be entered. This property is only used when the href property is set.

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

Parameters:
{string}sTarget New value for property target
Returns:
{sap.m.Link} Reference to this in order to allow method chaining
setText(sText): sap.m.Link
Sets a new value for property text.

Link text to be displayed.

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

Default value is .

Parameters:
{string}sText New value for property text
Returns:
{sap.m.Link} Reference to this in order to allow method chaining
setTextAlign(sTextAlign): sap.m.Link
Sets a new value for property textAlign.

Sets the horizontal alignment of the text.

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

Default value is Initial.

Parameters:
{sap.ui.core.TextAlign}sTextAlign New value for property textAlign
Since:
1.28.0
Returns:
{sap.m.Link} Reference to this in order to allow method chaining
setTextDirection(sTextDirection): sap.m.Link
Sets a new value for property textDirection.

This property specifies the element's text directionality with enumerated options. By default, the control inherits text direction from the parent DOM.

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

Default value is Inherit.

Parameters:
{sap.ui.core.TextDirection}sTextDirection New value for property textDirection
Since:
1.28.0
Returns:
{sap.m.Link} Reference to this in order to allow method chaining
setWidth(sWidth): sap.m.Link
Sets a new value for property width.

Determines the width of the link (CSS-size such as % or px). When it is set, this is the exact size. When left blank, the text defines the size.

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.Link} Reference to this in order to allow method chaining
setWrapping(bWrapping): sap.m.Link
Sets a new value for property wrapping.

Determines whether the link text is allowed to wrap when there is not sufficient space.

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

Default value is false.

Parameters:
{boolean}bWrapping New value for property wrapping
Returns:
{sap.m.Link} Reference to this in order to allow method chaining