class sap.ui.core.tmpl.TemplateControl

Visiblity: public
UX Guidelines:
Implements:
Available since: N/A
Module: sap/ui/core/tmpl/TemplateControl
Application Component: CA-UI5-COR

This is the base class for all template controls. Template controls are declared based on templates.


Constructor

Constructor for a new tmpl/TemplateControl.

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.core.tmpl.TemplateControl(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


Properties

Name Type Default Value Description
context object

The context is a data object. It can be used for default template expressions. A change of the context object leads to a re-rendering whereas a change of a nested property of the context object doesn't. By default the context is an empty object.

Visibility: public

Borrowed Properties

Name Type Default Value Description
blocked boolean false

Whether the control is currently in blocked state.

Visibility: public
busy boolean false

Whether the control is currently in busy state.

Visibility: public
busyIndicatorDelay int 1000

The delay in milliseconds, after which the busy indicator will show up for this control.

Visibility: public
busyIndicatorSize sap.ui.core.BusyIndicatorSize Medium

The size of the BusyIndicator. For controls with a width smaller 3rem a sap.ui.core.BusyIndicatorSize.Small should be used. If the size could vary in width and the width could get smaller than 3rem, the sap.ui.core.BusyIndicatorSize.Auto option could be used. The default is set to sap.ui.core.BusyIndicatorSize.Medium For a full screen BusyIndicator use sap.ui.core.BusyIndicatorSize.Large.

Since: 1.54.

Visibility: public
fieldGroupIds string[]

The IDs of a logical field group that this control belongs to.

All fields in a logical field group should share the same fieldGroupId. Once a logical field group is left, the validateFieldGroup event is fired.

For backward compatibility with older releases, field group IDs are syntactically not limited, but it is suggested to use only valid sap.ui.core.IDs.

See #attachValidateFieldGroup or consult the Field Group documentation.

Since: 1.31.

Visibility: public
visible boolean true

Whether the control should be visible on the screen.

If set to false, a placeholder will be rendered to mark the location of the invisible control in the DOM of the current page. The placeholder will be hidden and have zero dimensions (display: none).

Also see InvisibleRenderer.

Visibility: public

Aggregations

Default Aggregation:

Name Cardinality Type Description
controls 0..n sap.ui.core.Control

The nested controls of the template control

Borrowed Aggregations

Name Cardinality Type Description
customData 0..n sap.ui.core.CustomData

Custom Data, a data structure like a map containing arbitrary key value pairs.

dependents 0..n sap.ui.core.Element

Dependents are not rendered, but their databinding context and lifecycle are bound to the aggregating Element.

Since: 1.19.

dragDropConfig 0..n sap.ui.core.dnd.DragDropBase

Defines the drag-and-drop configuration. Note: This configuration might be ignored due to control metadata restrictions.

Since: 1.56.

layoutData 0..1 sap.ui.core.LayoutData

Defines the layout constraints for this control when it is used inside a Layout. LayoutData classes are typed classes and must match the embedding Layout. See VariantLayoutData for aggregating multiple alternative LayoutData instances to a single Element.

tooltip 0..1 sap.ui.core.TooltipBase

The tooltip that should be shown for this Element.

In the most simple case, a tooltip is a string that will be rendered by the control and displayed by the browser when the mouse pointer hovers over the control's DOM. In this variant, tooltip behaves like a simple control property.

Controls need to explicitly support this kind of tooltip as they have to render it, but most controls do. Exceptions will be documented for the corresponding controls (e.g. sap.ui.core.HTML does not support tooltips).

Alternatively, tooltip can act like a 0..1 aggregation and can be set to a tooltip control (an instance of a subclass of sap.ui.core.TooltipBase). In that case, the framework will take care of rendering the tooltip control in a popup-like manner. Such a tooltip control can display arbitrary content, not only a string.

UI5 currently does not provide a recommended implementation of TooltipBase as the use of content-rich tooltips is discouraged by the Fiori Design Guidelines. Existing subclasses of TooltipBase therefore have been deprecated. However, apps can still subclass from TooltipBase and create their own implementation when needed (potentially taking the deprecated implementations as a starting point).

See the section Using Tooltips in the Fiori Design Guideline.


Associations

Name Cardinality Type Description
template 0..1 sap.ui.core.tmpl.Template

The template on which the template control is based on.


Events Overview

Event Description
afterRendering

Fired when the Template Control has been (re-)rendered and its HTML is present in the DOM.

beforeRendering

Fired before this Template Control is re-rendered. Use to unbind event handlers from HTML elements etc.

afterRendering

Fired when the Template Control has been (re-)rendered and its HTML is present in the DOM.

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

beforeRendering

Fired before this Template Control is re-rendered. Use to unbind event handlers from HTML elements etc.

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

Methods Overview

Method Description
attachAfterRendering

Attaches event handler fnFunction to the afterRendering event of this sap.ui.core.tmpl.TemplateControl.

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.core.tmpl.TemplateControl itself.

Fired when the Template Control has been (re-)rendered and its HTML is present in the DOM.

attachBeforeRendering

Attaches event handler fnFunction to the beforeRendering event of this sap.ui.core.tmpl.TemplateControl.

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.core.tmpl.TemplateControl itself.

Fired before this Template Control is re-rendered. Use to unbind event handlers from HTML elements etc.

bindList

Creates a pseudo binding for an aggregation to get notified once the property changes to invalidate the control and trigger a re-rendering.

bindProp

Creates a pseudo binding for a property to get notified once the property changes to invalidate the control and trigger a re-rendering.

createControl

compiles (creates and registers) a new control

createDOMElement

compiles (creates and registers) a new DOM element

detachAfterRendering

Detaches event handler fnFunction from the afterRendering event of this sap.ui.core.tmpl.TemplateControl.

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

detachBeforeRendering

Detaches event handler fnFunction from the beforeRendering event of this sap.ui.core.tmpl.TemplateControl.

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

sap.ui.core.tmpl.TemplateControl.extend

Creates a new subclass of class sap.ui.core.tmpl.TemplateControl 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.

fireAfterRendering

Fires event afterRendering to attached listeners.

fireBeforeRendering

Fires event beforeRendering to attached listeners.

getContext

Gets current value of property context.

The context is a data object. It can be used for default template expressions. A change of the context object leads to a re-rendering whereas a change of a nested property of the context object doesn't. By default the context is an empty object.

sap.ui.core.tmpl.TemplateControl.getMetadata

Returns a metadata object for class sap.ui.core.tmpl.TemplateControl.

getTemplate

ID of the element which is the current target of the association template, or null.

getTemplateRenderer

Returns the instance specific renderer for an anonymous template control.

isInline

checks whether the control is inline or not

setContext

Sets a new value for property context.

The context is a data object. It can be used for default template expressions. A change of the context object leads to a re-rendering whereas a change of a nested property of the context object doesn't. By default the context is an empty object.

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

setTemplate

Sets the associated template.

setTemplateRenderer

Sets the instance specific renderer for an anonymous template control.

attachAfterRendering

Attaches event handler fnFunction to the afterRendering event of this sap.ui.core.tmpl.TemplateControl.

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.core.tmpl.TemplateControl itself.

Fired when the Template Control has been (re-)rendered and its HTML is present in the DOM.

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.core.tmpl.TemplateControl itself

attachBeforeRendering

Attaches event handler fnFunction to the beforeRendering event of this sap.ui.core.tmpl.TemplateControl.

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.core.tmpl.TemplateControl itself.

Fired before this Template Control is re-rendered. Use to unbind event handlers from HTML elements etc.

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.core.tmpl.TemplateControl itself

bindList

Creates a pseudo binding for an aggregation to get notified once the property changes to invalidate the control and trigger a re-rendering.

Param Type DefaultValue Description
sPath string

the binding path

bindProp

Creates a pseudo binding for a property to get notified once the property changes to invalidate the control and trigger a re-rendering.

Param Type DefaultValue Description
sPath string

the binding path

createControl

compiles (creates and registers) a new control

Param Type DefaultValue Description
mSettings object

the settings for the new control

sParentPath string

the parent path for the control

bDoNotAdd boolean

if true, then the control will not be added to the _controls aggregation

oView sap.ui.core.mvc.View

createDOMElement

compiles (creates and registers) a new DOM element

Param Type DefaultValue Description
mSettings object

the settings for the new DOM element

sParentPath string

the parent path for the DOM element

bDoNotAdd boolean

if true, then the control will not be added to the _controls aggregation

detachAfterRendering

Detaches event handler fnFunction from the afterRendering event of this sap.ui.core.tmpl.TemplateControl.

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

detachBeforeRendering

Detaches event handler fnFunction from the beforeRendering event of this sap.ui.core.tmpl.TemplateControl.

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.core.tmpl.TemplateControl.extend

Creates a new subclass of class sap.ui.core.tmpl.TemplateControl 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

fireAfterRendering

Fires event afterRendering to attached listeners.

Param Type DefaultValue Description
mParameters object

Parameters to pass along with the event

fireBeforeRendering

Fires event beforeRendering to attached listeners.

Param Type DefaultValue Description
mParameters object

Parameters to pass along with the event

getContext

Gets current value of property context.

The context is a data object. It can be used for default template expressions. A change of the context object leads to a re-rendering whereas a change of a nested property of the context object doesn't. By default the context is an empty object.

sap.ui.core.tmpl.TemplateControl.getMetadata

Returns a metadata object for class sap.ui.core.tmpl.TemplateControl.

getTemplate

ID of the element which is the current target of the association template, or null.

getTemplateRenderer

Returns the instance specific renderer for an anonymous template control.

isInline

checks whether the control is inline or not

setContext

Sets a new value for property context.

The context is a data object. It can be used for default template expressions. A change of the context object leads to a re-rendering whereas a change of a nested property of the context object doesn't. By default the context is an empty object.

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

Param Type DefaultValue Description
oContext object

New value for property context

setTemplate

Sets the associated template.

Param Type DefaultValue Description
oTemplate sap.ui.core.ID sap.ui.core.tmpl.Template

ID of an element which becomes the new target of this template association; alternatively, an element instance may be given

setTemplateRenderer

Sets the instance specific renderer for an anonymous template control.

Param Type DefaultValue Description
fnRenderer function

the instance specific renderer function