Class sap.m.InputBaseModule: sap/m/InputBase

extends Control
implements IFormContent
known direct subclasses: ComboBoxTextField, DatePicker, Input, MaskInput, TextArea

The sap.m.InputBase control provides a basic functionality for input controls.
Since: 1.12.0.
Constructor Summary
new sap.m.InputBase(sId?, mSettings?)Constructor for a new sap.m.InputBase.
Field Summary
bShowLabelAsPlaceholderUse labels as placeholder configuration.
Event Summary
change(oControlEvent)Is fired when the text in the input field has changed and the focus leaves the input field or the enter key is pressed.
Events borrowed from class sap.ui.core.Control
Method Summary
sap.m.InputBase.extend(sClassName, oClassInfo?, FNMetaImpl?)Creates a new subclass of class sap.m.InputBase with name sClassName and enriches it with the information contained in oClassInfo.
sap.m.InputBase.getMetadata()Returns a metadata object for class sap.m.InputBase.
addAriaLabelledBy(vAriaLabelledBy)Adds some ariaLabelledBy into the association ariaLabelledBy.
applyFocusInfo(oFocusInfo)Applies the focus info.
attachChange(oData?, fnFunction, oListener?)Attaches event handler fnFunction to the change event of this sap.m.InputBase.
bindValue(oBindingInfo)Binds property value to model data.
closeValueStateMessage()Close value state message popup.
detachChange(fnFunction, oListener)Detaches event handler fnFunction from the change event of this sap.m.InputBase.
fireChange(mParameters?)Fires event change to attached listeners.
fireChangeEvent(sValue, oParams?)Fires the change event for the listeners
getAriaLabelledBy()Returns array of IDs of the elements which are the current targets of the association ariaLabelledBy.
getDomRefForValueStateMessage()Gets the DOM element reference where the message popup is attached.
getEditable()Gets current value of property editable.
getEnabled()Gets current value of property enabled.
getFocusInfo()Returns an object representing the serialized focus information.
getLabels()Gets the labels referencing this control.
getName()Gets current value of property name.
getPlaceholder()Gets current value of property placeholder.
getRequired()Gets current value of property required.
getSelectedText()Retrieves the selected text.
getShowValueStateMessage()Gets current value of property showValueStateMessage.
getTextAlign()Gets current value of property textAlign.
getTextDirection()Gets current value of property textDirection.
getValue()Gets current value of property value.
getValueState()Gets current value of property valueState.
getValueStateText()Gets current value of property valueStateText.
getWidth()Gets current value of property width.
onChange(oEvent, mParameters?)Handles the change event.
onValueRevertedByEscape(sValue)Hook method that gets called when the input value is reverted with hitting escape.
openValueStateMessage()Open value state message popup.
preventChangeOnFocusLeave(oEvent?)Hook method to prevent the change event from being fired when the text input field loses focus.
removeAllAriaLabelledBy()Removes all the controls in the association named ariaLabelledBy.
removeAriaLabelledBy(vAriaLabelledBy)Removes an ariaLabelledBy from the association named ariaLabelledBy.
selectText(iSelectionStart, iSelectionEnd)Selects the text within the input field between the specified start and end positions.
setEditable(bEditable)Sets a new value for property editable.
setEnabled(bEnabled)Sets a new value for property enabled.
setName(sName)Sets a new value for property name.
setPlaceholder(sPlaceholder)Sets a new value for property placeholder.
setRequired(bRequired)Sets a new value for property required.
setShowValueStateMessage(bShowValueStateMessage)Sets a new value for property showValueStateMessage.
setTextAlign(sTextAlign)Sets a new value for property textAlign.
setTextDirection(sTextDirection)Sets a new value for property textDirection.
setValue(sValue)Setter for property value.
setValueState(sValueState)Setter for property valueState.
setValueStateText(sText)Setter for property valueStateText.
setWidth(sWidth)Sets a new value for property width.
unbindValue()Unbinds property value from model data.
updateDomValue(sValue)Sets the DOM value of the input field and handles placeholder visibility.
bindToInputEvent(fnCallback)Registers an event listener to the browser input event.
Constructor Detail
new sap.m.InputBase(sId?, mSettings?)

Constructor for a new sap.m.InputBase.

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:

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

Parameters:
stringsId?ID for the new control, generated automatically if no ID is given
objectmSettings?Initial settings for the new control
Field Detail
bShowLabelAsPlaceholder
Use labels as placeholder configuration. It can be necessary for the subclasses to overwrite this when native placeholder usage causes undesired input events or when placeholder attribute is not supported for the specified type. https://html.spec.whatwg.org/multipage/forms.html#input-type-attr-summary
See:
sap.m.InputBase#oninput
Event Detail
change(oControlEvent)
Is fired when the text in the input field has changed and the focus leaves the input field or the enter key is pressed.
Parameters:
sap.ui.base.EventoControlEvent
sap.ui.base.EventProvideroControlEvent.getSource
objectoControlEvent.getParameters
stringoControlEvent.getParameters.valueThe new value of the control.
Method Detail
sap.m.InputBase.extend(sClassName, oClassInfo?, FNMetaImpl?): function

Creates a new subclass of class sap.m.InputBase 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:
stringsClassNameName of the class being created
objectoClassInfo?Object literal with information about the class
functionFNMetaImpl?Constructor function for the metadata object; if not given, it defaults to sap.ui.core.ElementMetadata
Returns:
functionCreated class / constructor function
sap.m.InputBase.getMetadata(): sap.ui.base.Metadata
Returns a metadata object for class sap.m.InputBase.
Returns:
sap.ui.base.MetadataMetadata object describing this class
addAriaLabelledBy(vAriaLabelledBy): sap.m.InputBase
Adds some ariaLabelledBy into the association ariaLabelledBy.
Parameters:
sap.ui.core.ID|sap.ui.core.ControlvAriaLabelledBythe ariaLabelledBy to add; if empty, nothing is inserted
Returns:
sap.m.InputBaseReference to this in order to allow method chaining
Since:
1.27.0
applyFocusInfo(oFocusInfo)
Applies the focus info. To be overwritten by subclasses.
Parameters:
objectoFocusInfo
attachChange(oData?, fnFunction, oListener?): sap.m.InputBase

Attaches event handler fnFunction to the change event of this sap.m.InputBase.

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

Is fired when the text in the input field has changed and the focus leaves the input field or the enter key is pressed.

Parameters:
objectoData?An application-specific payload object that will be passed to the event handler along with the event object when firing the event
functionfnFunctionThe function to be called when the event occurs
objectoListener?Context object to call the event handler with. Defaults to this sap.m.InputBase itself
Returns:
sap.m.InputBaseReference to this in order to allow method chaining
bindValue(oBindingInfo): sap.m.InputBase

Binds property value to model data.

See ManagedObject.bindProperty for a detailed description of the possible properties of oBindingInfo

Parameters:
objectoBindingInfoThe binding information
Returns:
sap.m.InputBaseReference to this in order to allow method chaining
closeValueStateMessage()
Close value state message popup.
Since:
1.26
detachChange(fnFunction, oListener): sap.m.InputBase

Detaches event handler fnFunction from the change event of this sap.m.InputBase.

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

Parameters:
functionfnFunctionThe function to be called, when the event occurs
objectoListenerContext object on which the given function had to be called
Returns:
sap.m.InputBaseReference to this in order to allow method chaining
fireChange(mParameters?): sap.m.InputBase
Fires event change to attached listeners.
Parameters:
objectmParameters?Parameters to pass along with the event
stringmParameters.value?The new value of the control.
Returns:
sap.m.InputBaseReference to this in order to allow method chaining
fireChangeEvent(sValue, oParams?)
Fires the change event for the listeners
Parameters:
StringsValuevalue of the input.
ObjectoParams?extra event parameters.
Since:
1.22.1
getAccessibilityInfo()
See:
sap.ui.core.Control#getAccessibilityInfo
getAriaLabelledBy(): sap.ui.core.ID[]
Returns array of IDs of the elements which are the current targets of the association ariaLabelledBy.
Returns:
sap.ui.core.ID[]
Since:
1.27.0
getDomRefForValueStateMessage(): object
Gets the DOM element reference where the message popup is attached.
Returns:
objectThe DOM element reference where the message popup is attached
Since:
1.26
getEditable(): boolean

Gets current value of property editable.

Defines whether the control can be modified by the user or not. Note: A user can tab to non-editable control, highlight it, and copy the text from it.

Default value is true.

Returns:
booleanValue of property editable
Since:
1.12.0
getEnabled(): boolean

Gets current value of property enabled.

Indicates whether the user can interact with the control or not. Note: Disabled controls cannot be focused and they are out of the tab-chain.

Default value is true.

Returns:
booleanValue of property enabled
getFocusInfo(): object
Returns an object representing the serialized focus information. To be overwritten by subclasses.
Returns:
objectAn object representing the serialized focus information.
getLabels(): sap.m.Label[]
Gets the labels referencing this control.
Returns:
sap.m.Label[]Array of objects which are the current targets of the ariaLabelledBy association and the labels referencing this control.
Since:
1.48
getName(): string

Gets current value of property name.

Defines the name of the control for the purposes of form submission.

Returns:
stringValue of property name
getPlaceholder(): string

Gets current value of property placeholder.

Defines a short hint intended to aid the user with data entry when the control has no value.

Returns:
stringValue of property placeholder
getRequired(): boolean

Gets current value of property required.

Indicates that user input is required. This property is only needed for accessibility purposes when a single relationship between the field and a label (see aggregation labelFor of sap.m.Label) cannot be established (e.g. one label should label multiple fields).

Default value is false.

Returns:
booleanValue of property required
Since:
1.38.4
getSelectedText(): string
Retrieves the selected text. Only supported for input control's type of Text, Url, Tel and Password.
Returns:
stringThe selected text.
Since:
1.32
getShowValueStateMessage(): boolean

Gets current value of property showValueStateMessage.

Indicates whether the value state message should be shown or not.

Default value is true.

Returns:
booleanValue of property showValueStateMessage
Since:
1.26.0
getTextAlign(): sap.ui.core.TextAlign

Gets current value of property textAlign.

Defines the horizontal alignment of the text that is shown inside the input field.

Default value is Initial.

Returns:
sap.ui.core.TextAlignValue of property textAlign
Since:
1.26.0
getTextDirection(): sap.ui.core.TextDirection

Gets current value of property textDirection.

Defines the text directionality of the input field, e.g. RTL, LTR

Default value is Inherit.

Returns:
sap.ui.core.TextDirectionValue of property textDirection
Since:
1.28.0
getValue(): string

Gets current value of property value.

Defines the value of the control.

Returns:
stringValue of property value
getValueState(): sap.ui.core.ValueState

Gets current value of property valueState.

Visualizes the validation state of the control, e.g. Error, Warning, Success.

Default value is None.

Returns:
sap.ui.core.ValueStateValue of property valueState
getValueStateText(): string

Gets current value of property valueStateText.

Defines the text that appears in the value state message pop-up. If this is not specified, a default text is shown from the resource bundle.

Returns:
stringValue of property valueStateText
Since:
1.26.0
getWidth(): sap.ui.core.CSSSize

Gets current value of property width.

Defines the width of the control.

Returns:
sap.ui.core.CSSSizeValue of property width
onChange(oEvent, mParameters?): true|undefined
Handles the change event.
Parameters:
objectoEvent
objectmParameters?Additional event parameters to be passed in to the change event handler if the value has changed
Returns:
true|undefinedtrue when change event is fired
onValueRevertedByEscape(sValue)
Hook method that gets called when the input value is reverted with hitting escape. It may require to re-implement this method from sub classes for control specific behaviour.
Parameters:
StringsValueReverted value of the input.
Since:
1.26
openValueStateMessage()
Open value state message popup.
Since:
1.26
preventChangeOnFocusLeave(oEvent?): boolean
Hook method to prevent the change event from being fired when the text input field loses focus.
Parameters:
jQuery.EventoEvent?The event object.
Returns:
booleanWhether or not the change event should be prevented.
Since:
1.46
removeAllAriaLabelledBy(): sap.ui.core.ID[]
Removes all the controls in the association named ariaLabelledBy.
Returns:
sap.ui.core.ID[]An array of the removed elements (might be empty)
Since:
1.27.0
removeAriaLabelledBy(vAriaLabelledBy): sap.ui.core.ID
Removes an ariaLabelledBy from the association named ariaLabelledBy.
Parameters:
int|sap.ui.core.ID|sap.ui.core.ControlvAriaLabelledByThe ariaLabelledBy to be removed or its index or ID
Returns:
sap.ui.core.IDThe removed ariaLabelledBy or null
Since:
1.27.0
selectText(iSelectionStart, iSelectionEnd): sap.m.InputBase
Selects the text within the input field between the specified start and end positions. Only supported for input control's type of Text, Url, Tel and Password.
Parameters:
intiSelectionStartThe index into the text at which the first selected character is located.
intiSelectionEndThe index into the text at which the last selected character is located.
Returns:
sap.m.InputBasethis to allow method chaining.
Since:
1.22.1
setEditable(bEditable): sap.m.InputBase

Sets a new value for property editable.

Defines whether the control can be modified by the user or not. Note: A user can tab to non-editable control, highlight it, and copy the text from it.

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

Default value is true.

Parameters:
booleanbEditableNew value for property editable
Returns:
sap.m.InputBaseReference to this in order to allow method chaining
Since:
1.12.0
setEnabled(bEnabled): sap.m.InputBase

Sets a new value for property enabled.

Indicates whether the user can interact with the control or not. Note: Disabled controls cannot be focused and they are out of the tab-chain.

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

Default value is true.

Parameters:
booleanbEnabledNew value for property enabled
Returns:
sap.m.InputBaseReference to this in order to allow method chaining
setName(sName): sap.m.InputBase

Sets a new value for property name.

Defines the name of the control for the purposes of form submission.

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

Parameters:
stringsNameNew value for property name
Returns:
sap.m.InputBaseReference to this in order to allow method chaining
setPlaceholder(sPlaceholder): sap.m.InputBase

Sets a new value for property placeholder.

Defines a short hint intended to aid the user with data entry when the control has no value.

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

Parameters:
stringsPlaceholderNew value for property placeholder
Returns:
sap.m.InputBaseReference to this in order to allow method chaining
setRequired(bRequired): sap.m.InputBase

Sets a new value for property required.

Indicates that user input is required. This property is only needed for accessibility purposes when a single relationship between the field and a label (see aggregation labelFor of sap.m.Label) cannot be established (e.g. one label should label multiple fields).

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

Default value is false.

Parameters:
booleanbRequiredNew value for property required
Returns:
sap.m.InputBaseReference to this in order to allow method chaining
Since:
1.38.4
setShowValueStateMessage(bShowValueStateMessage): sap.m.InputBase

Sets a new value for property showValueStateMessage.

Indicates whether the value state message should be shown or not.

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

Default value is true.

Parameters:
booleanbShowValueStateMessageNew value for property showValueStateMessage
Returns:
sap.m.InputBaseReference to this in order to allow method chaining
Since:
1.26.0
setTextAlign(sTextAlign): sap.m.InputBase

Sets a new value for property textAlign.

Defines the horizontal alignment of the text that is shown inside the input field.

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.TextAlignsTextAlignNew value for property textAlign
Returns:
sap.m.InputBaseReference to this in order to allow method chaining
Since:
1.26.0
setTextDirection(sTextDirection): sap.m.InputBase

Sets a new value for property textDirection.

Defines the text directionality of the input field, e.g. RTL, LTR

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.TextDirectionsTextDirectionNew value for property textDirection
Returns:
sap.m.InputBaseReference to this in order to allow method chaining
Since:
1.28.0
setValue(sValue): sap.m.InputBase

Setter for property value.

Default value is empty/undefined.

Parameters:
stringsValueNew value for property value.
Returns:
sap.m.InputBasethis to allow method chaining.
setValueState(sValueState): sap.m.InputBase

Setter for property valueState.

Default value is None.

Parameters:
sap.ui.core.ValueStatesValueStateNew value for property valueState.
Returns:
sap.m.InputBasethis to allow method chaining.
setValueStateText(sText): sap.m.InputBase

Setter for property valueStateText.

Default value is empty/undefined.

Parameters:
stringsTextNew value for property valueStateText.
Returns:
sap.m.InputBasethis to allow method chaining
Since:
1.26
setWidth(sWidth): sap.m.InputBase

Sets a new value for property width.

Defines the width of the control.

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

Parameters:
sap.ui.core.CSSSizesWidthNew value for property width
Returns:
sap.m.InputBaseReference to this in order to allow method chaining
unbindValue(): sap.m.InputBase
Unbinds property value from model data.
Returns:
sap.m.InputBaseReference to this in order to allow method chaining
updateDomValue(sValue): sap.m.InputBase
Sets the DOM value of the input field and handles placeholder visibility.
Parameters:
stringsValuevalue of the input field.
Returns:
sap.m.InputBasethis to allow method chaining.
Since:
1.22
bindToInputEvent(fnCallback): sap.m.InputBase
Registers an event listener to the browser input event.
Parameters:
functionfnCallbackFunction to be called when the value of the input element is changed.
Returns:
sap.m.InputBasethis to allow method chaining.
Deprecated API:
Since 1.22. Instead, use event delegation(oninput) to listen input event.