Package io.jmix.ui.component.impl
Class TextFieldImpl<V>
java.lang.Object
io.jmix.ui.component.impl.AbstractComponent<T>
io.jmix.ui.component.impl.AbstractValueComponent<T,P,V>
io.jmix.ui.component.impl.AbstractField<JmixTextField,String,V>
io.jmix.ui.component.impl.TextFieldImpl<V>
- All Implemented Interfaces:
AttachNotifier
,Buffered
,Component
,Component.BelongToFrame
,Component.Editable
,Component.Focusable
,Component.HasCaption
,Component.HasDescription
,Component.HasIcon
,Component.HasXmlDescriptor
,Component.Wrapper
,HasValueSource<V>
,Field<V>
,HasContextHelp
,HasConversionErrorMessage
,HasDatatype<V>
,HasDebugId
,HasFormatter<V>
,HasHtmlCaption
,HasHtmlDescription
,HasHtmlSanitizer
,HasInputPrompt
,HasValidator<V>
,HasValue<V>
,Requirable
,TextField<V>
,TextInputField<V>
,TextInputField.CaseConversionSupported
,TextInputField.CursorPositionSupported
,TextInputField.EnterPressNotifier
,TextInputField.HtmlNameSupported
,TextInputField.MaxLengthLimited
,TextInputField.TextChangeNotifier
,TextInputField.TextSelectionSupported
,TextInputField.TrimSupported
,Validatable
,org.springframework.beans.factory.InitializingBean
public class TextFieldImpl<V>
extends AbstractField<JmixTextField,String,V>
implements TextField<V>, org.springframework.beans.factory.InitializingBean
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.jmix.ui.component.Component
Component.Alignment, Component.BelongToFrame, Component.Disposable, Component.Editable, Component.Focusable, Component.HasCaption, Component.HasDescription, Component.HasIcon, Component.HasXmlDescriptor, Component.Wrapper
Nested classes/interfaces inherited from interface io.jmix.ui.component.HasContextHelp
HasContextHelp.ContextHelpIconClickEvent
Nested classes/interfaces inherited from interface io.jmix.ui.component.HasValue
HasValue.ValueChangeEvent<V>
Nested classes/interfaces inherited from interface io.jmix.ui.component.TextInputField
TextInputField.CaseConversion, TextInputField.CaseConversionSupported, TextInputField.CursorPositionSupported, TextInputField.EnterPressEvent, TextInputField.EnterPressNotifier, TextInputField.HtmlNameSupported, TextInputField.MaxLengthLimited, TextInputField.TextChangeEvent, TextInputField.TextChangeEventMode, TextInputField.TextChangeNotifier, TextInputField.TextSelectionSupported, TextInputField.TrimSupported
-
Field Summary
Modifier and TypeFieldDescriptionprotected String
protected DataAwareComponentsTools
protected com.vaadin.shared.Registration
protected Locale
protected boolean
Fields inherited from class io.jmix.ui.component.impl.AbstractField
editable, parentEditableChangeListener, validators, VALIDATORS_LIST_INITIAL_CAPACITY
Fields inherited from class io.jmix.ui.component.impl.AbstractValueComponent
internalValue, uiTestIdsSupport, valueBinding
Fields inherited from class io.jmix.ui.component.impl.AbstractComponent
alignment, applicationContext, component, contextHelpIconClickHandler, contextHelpIconClickListener, descriptionAsHtml, element, frame, htmlSanitizerEnabled, icon, ICON_STYLE, id, parent
Fields inherited from interface io.jmix.ui.component.Component
AUTO_SIZE, AUTO_SIZE_PX, FULL_SIZE
Fields inherited from interface io.jmix.ui.component.TextField
NAME, TYPE_BIGDECIMAL, TYPE_DATE, TYPE_DATETIME, TYPE_DEFAULT, TYPE_DOUBLE, TYPE_INTEGER, TYPE_LOCALDATE, TYPE_LOCALDATETIME, TYPE_LONG, TYPE_OFFSETTIME, TYPE_STRING, TYPE_TIME
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionAdds a listener that is invoked when the user presses Enter.Adds a listener that is fired when the component value is changed.void
void
commit()
Updates all changes since the previous commit to the data source.protected void
componentValueChanged
(String prevComponentValue, String newComponentValue, boolean isUserOriginated) protected V
convertToModel
(String componentRawValue) protected String
convertToPresentation
(V modelValue) protected JmixTextField
void
discard()
Discards all changes since last commit.protected void
fireTextChangeEvent
(String newComponentValue) void
focus()
Sets focus to this componentprotected String
int
Returns a string representation of the value.int
Gets the tabulator index of theHasTabIndex
component.int
Gets the timeout used to fireTextInputField.TextChangeEvent
s andHasValue.ValueChangeEvent
s when theTextInputField.TextChangeNotifier.getTextChangeEventMode()
isTextInputField.TextChangeEventMode.LAZY
orTextInputField.TextChangeEventMode.TIMEOUT
.protected void
initComponent
(JmixTextField component) protected void
boolean
boolean
isEmpty()
boolean
Tests if the value stored in the object has been modified since it was last updated from the data source.boolean
void
void
setBuffered
(boolean buffered) Sets the buffered mode.void
setCaseConversion
(TextInputField.CaseConversion caseConversion) Disable automatic case conversion or enable with chosen modevoid
setConversionErrorMessage
(String conversionErrorMessage) Sets custom conversion error message that is used when value doesn't correspond to datatype.void
setCurrentAuthentication
(CurrentAuthentication currentAuthentication) void
setCursorPosition
(int position) Sets the cursor position in the field.void
setDataAwareComponentsTools
(DataAwareComponentsTools dataAwareComponentsTools) void
setDatatype
(Datatype<V> datatype) Sets the givendatatype
to the component.void
setFormatter
(Formatter<? super V> formatter) void
setHtmlName
(String htmlName) Sets the givenhtmlName
as a value of "name" HTML attribute.void
setInputPrompt
(String inputPrompt) Sets the input prompt - a textual prompt that is displayed when the field would otherwise be empty, to prompt the user for input.void
setMaxLength
(int maxLength) void
setSelectionRange
(int pos, int length) void
setTabIndex
(int tabIndex) Sets the tabulator index of theFocusable
component.void
Sets the mode how the TextField triggersTextInputField.TextChangeEvent
s andHasValue.ValueChangeEvent
s.void
setTextChangeTimeout
(int timeout) The text change timeout modifies how often text change events are communicated to the application whenTextInputField.TextChangeNotifier.getTextChangeEventMode()
isTextInputField.TextChangeEventMode.LAZY
orTextInputField.TextChangeEventMode.TIMEOUT
.void
setTrimming
(boolean trimming) protected void
valueBindingConnected
(ValueSource<V> valueSource) Methods inherited from class io.jmix.ui.component.impl.AbstractField
addValidator, attachValueChangeListener, getDatatypeConversionErrorMsg, getDefaultRequiredMessage, getErrorMessage, getRequiredMessage, getValidators, isEditable, isRequired, isValid, removeValidator, setEditable, setEditableToComponent, setParent, setRequired, setRequiredMessage, setupComponentErrorProvider, triggerValidators, validate
Methods inherited from class io.jmix.ui.component.impl.AbstractValueComponent
addValueChangeListener, fieldValueEquals, getValue, getValueSource, setUiTestId, setUiTestIdsSupport, setValue, setValueSource, setValueToPresentation, valueBindingActivated
Methods inherited from class io.jmix.ui.component.impl.AbstractComponent
addAttachListener, addDetachListener, addStyleName, assignDebugId, attached, detached, getAlignment, getCaption, getComponent, getComposition, getContextHelpIconClickHandler, getContextHelpText, getDebugId, getDescription, getEventHub, getFrame, getHeight, getHeightSizeUnit, getHtmlSanitizer, getIcon, getIconName, getIconResource, getId, getParent, getStyleName, getUiComponentProperties, getUiProperties, getWidth, getWidthSizeUnit, getXmlDescriptor, hasSubscriptions, hasValidationError, isAttached, isCaptionAsHtml, isContextHelpTextHtmlEnabled, isDescriptionAsHtml, isEnabled, isEnabledRecursive, isHtmlSanitizerEnabled, isResponsive, isVisible, isVisibleRecursive, onContextHelpIconClick, publish, removeStyleName, sanitize, setAlignment, setApplicationContext, setCaption, setCaptionAsHtml, setContextHelpIconClickHandler, setContextHelpText, setContextHelpTextHtmlEnabled, setDebugId, setDescription, setDescriptionAsHtml, setEnabled, setFrame, setHeight, setHtmlSanitizerEnabled, setIcon, setIconFromSet, setId, setResponsive, setStyleName, setValidationError, setVisible, setWidth, setXmlDescriptor, unsubscribe, unwrap, unwrapComposition, unwrapCompositionOrNull, unwrapOrNull, withUnwrapped, withUnwrappedComposition
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.jmix.ui.component.Component
addStyleName, getAlignment, getHeight, getHeightSizeUnit, getId, getParent, getStyleName, getWidth, getWidthSizeUnit, isEnabled, isEnabledRecursive, isResponsive, isVisible, isVisibleRecursive, removeStyleName, setAlignment, setEnabled, setHeight, setHeightAuto, setHeightFull, setId, setParent, setResponsive, setSizeAuto, setSizeFull, setStyleName, setVisible, setWidth, setWidthAuto, setWidthFull, unwrap, unwrapComposition, unwrapCompositionOrNull, unwrapOrNull, withUnwrapped, withUnwrappedComposition
Methods inherited from interface io.jmix.ui.component.Component.BelongToFrame
getFrame, setFrame
Methods inherited from interface io.jmix.ui.component.Component.Editable
isEditable, isEditableWithParent, setEditable
Methods inherited from interface io.jmix.ui.component.Component.Focusable
isFocusable, setFocusable
Methods inherited from interface io.jmix.ui.component.Component.HasCaption
getCaption, setCaption
Methods inherited from interface io.jmix.ui.component.Component.HasDescription
getDescription, setDescription
Methods inherited from interface io.jmix.ui.component.Component.HasIcon
getIcon, setIcon, setIconFromSet
Methods inherited from interface io.jmix.ui.component.HasContextHelp
getContextHelpIconClickHandler, getContextHelpText, isContextHelpTextHtmlEnabled, setContextHelpIconClickHandler, setContextHelpText, setContextHelpTextHtmlEnabled
Methods inherited from interface io.jmix.ui.component.HasHtmlCaption
isCaptionAsHtml, setCaptionAsHtml
Methods inherited from interface io.jmix.ui.component.HasHtmlDescription
isDescriptionAsHtml, setDescriptionAsHtml
Methods inherited from interface io.jmix.ui.component.HasHtmlSanitizer
isHtmlSanitizerEnabled, setHtmlSanitizerEnabled
Methods inherited from interface io.jmix.ui.component.HasValidator
addValidator, addValidators, getValidators, removeValidator
Methods inherited from interface io.jmix.ui.component.HasValue
addValueChangeListener, clear, getEmptyValue, getValue, setValue
Methods inherited from interface io.jmix.ui.component.data.HasValueSource
getValueSource, setValueSource
Methods inherited from interface io.jmix.ui.component.Requirable
getRequiredMessage, isRequired, setRequired, setRequiredMessage
Methods inherited from interface io.jmix.ui.component.Validatable
isValid, isValidateOnCommit, validate
-
Field Details
-
datatype
-
formatter
-
locale
-
trimming
protected boolean trimming -
enterShortcutRegistration
protected com.vaadin.shared.Registration enterShortcutRegistration -
conversionErrorMessage
-
dataAwareComponentsTools
-
-
Constructor Details
-
TextFieldImpl
public TextFieldImpl()
-
-
Method Details
-
setDataAwareComponentsTools
@Autowired public void setDataAwareComponentsTools(DataAwareComponentsTools dataAwareComponentsTools) -
setCurrentAuthentication
-
createComponent
-
afterPropertiesSet
public void afterPropertiesSet()- Specified by:
afterPropertiesSet
in interfaceorg.springframework.beans.factory.InitializingBean
-
initComponent
-
valueBindingConnected
- Overrides:
valueBindingConnected
in classAbstractValueComponent<JmixTextField,
String, V>
-
convertToPresentation
- Overrides:
convertToPresentation
in classAbstractValueComponent<JmixTextField,
String, V> - Throws:
ConversionException
-
convertToModel
- Overrides:
convertToModel
in classAbstractValueComponent<JmixTextField,
String, V> - Throws:
ConversionException
-
setConversionErrorMessage
Description copied from interface:HasConversionErrorMessage
Sets custom conversion error message that is used when value doesn't correspond to datatype.- Specified by:
setConversionErrorMessage
in interfaceHasConversionErrorMessage
- Parameters:
conversionErrorMessage
- custom conversion error message
-
getConversionErrorMessage
- Specified by:
getConversionErrorMessage
in interfaceHasConversionErrorMessage
- Returns:
- custom conversion error message
-
getConversionErrorMessageInternal
-
componentValueChanged
protected void componentValueChanged(String prevComponentValue, String newComponentValue, boolean isUserOriginated) - Overrides:
componentValueChanged
in classAbstractValueComponent<JmixTextField,
String, V>
-
isEmpty
public boolean isEmpty() -
getDatatype
- Specified by:
getDatatype
in interfaceHasDatatype<V>
- Returns:
- a datatype that is used by this component
-
setDatatype
Description copied from interface:HasDatatype
Sets the givendatatype
to the component. Its value will be formatted according to this datatype.- Specified by:
setDatatype
in interfaceHasDatatype<V>
- Parameters:
datatype
-Datatype
instance
-
getCaseConversion
- Specified by:
getCaseConversion
in interfaceTextInputField.CaseConversionSupported
- Returns:
- conversion mode or null if automatic conversion is disabled
-
setCaseConversion
Description copied from interface:TextInputField.CaseConversionSupported
Disable automatic case conversion or enable with chosen mode- Specified by:
setCaseConversion
in interfaceTextInputField.CaseConversionSupported
-
getFormatter
- Specified by:
getFormatter
in interfaceHasFormatter<V>
-
setFormatter
- Specified by:
setFormatter
in interfaceHasFormatter<V>
-
getMaxLength
public int getMaxLength()- Specified by:
getMaxLength
in interfaceTextInputField.MaxLengthLimited
-
setMaxLength
public void setMaxLength(int maxLength) - Specified by:
setMaxLength
in interfaceTextInputField.MaxLengthLimited
-
isTrimming
public boolean isTrimming()- Specified by:
isTrimming
in interfaceTextInputField.TrimSupported
-
setTrimming
public void setTrimming(boolean trimming) - Specified by:
setTrimming
in interfaceTextInputField.TrimSupported
-
getInputPrompt
- Specified by:
getInputPrompt
in interfaceHasInputPrompt
- Returns:
- current input prompt.
-
setInputPrompt
Description copied from interface:HasInputPrompt
Sets the input prompt - a textual prompt that is displayed when the field would otherwise be empty, to prompt the user for input.- Specified by:
setInputPrompt
in interfaceHasInputPrompt
- Parameters:
inputPrompt
- input prompt
-
setCursorPosition
public void setCursorPosition(int position) Description copied from interface:TextInputField.CursorPositionSupported
Sets the cursor position in the field.- Specified by:
setCursorPosition
in interfaceTextInputField.CursorPositionSupported
- Parameters:
position
- new cursor position
-
getRawValue
Description copied from interface:TextField
Returns a string representation of the value.- Specified by:
getRawValue
in interfaceTextField<V>
-
selectAll
public void selectAll()- Specified by:
selectAll
in interfaceTextInputField.TextSelectionSupported
-
setSelectionRange
public void setSelectionRange(int pos, int length) - Specified by:
setSelectionRange
in interfaceTextInputField.TextSelectionSupported
-
fireTextChangeEvent
-
setTextChangeTimeout
public void setTextChangeTimeout(int timeout) Description copied from interface:TextInputField.TextChangeNotifier
The text change timeout modifies how often text change events are communicated to the application whenTextInputField.TextChangeNotifier.getTextChangeEventMode()
isTextInputField.TextChangeEventMode.LAZY
orTextInputField.TextChangeEventMode.TIMEOUT
.- Specified by:
setTextChangeTimeout
in interfaceTextInputField.TextChangeNotifier
- Parameters:
timeout
- timeout in milliseconds
-
addTextChangeListener
Description copied from interface:TextInputField.TextChangeNotifier
Adds a listener that is fired when the component value is changed.- Specified by:
addTextChangeListener
in interfaceTextInputField.TextChangeNotifier
- Parameters:
listener
- a listener to add- Returns:
- a
Subscription
object
-
getTextChangeTimeout
public int getTextChangeTimeout()Description copied from interface:TextInputField.TextChangeNotifier
Gets the timeout used to fireTextInputField.TextChangeEvent
s andHasValue.ValueChangeEvent
s when theTextInputField.TextChangeNotifier.getTextChangeEventMode()
isTextInputField.TextChangeEventMode.LAZY
orTextInputField.TextChangeEventMode.TIMEOUT
.- Specified by:
getTextChangeTimeout
in interfaceTextInputField.TextChangeNotifier
- Returns:
- timeout in milliseconds
-
getTextChangeEventMode
- Specified by:
getTextChangeEventMode
in interfaceTextInputField.TextChangeNotifier
- Returns:
- the mode used to trigger
TextInputField.TextChangeEvent
s andHasValue.ValueChangeEvent
s.
-
setTextChangeEventMode
Description copied from interface:TextInputField.TextChangeNotifier
Sets the mode how the TextField triggersTextInputField.TextChangeEvent
s andHasValue.ValueChangeEvent
s.- Specified by:
setTextChangeEventMode
in interfaceTextInputField.TextChangeNotifier
- Parameters:
mode
- the new mode
-
addEnterPressListener
Description copied from interface:TextInputField.EnterPressNotifier
Adds a listener that is invoked when the user presses Enter.- Specified by:
addEnterPressListener
in interfaceTextInputField.EnterPressNotifier
- Parameters:
listener
- a listener to add- Returns:
- a
Subscription
-
internalRemoveEnterPressListener
-
focus
public void focus()Description copied from interface:Component.Focusable
Sets focus to this component- Specified by:
focus
in interfaceComponent.Focusable
-
getTabIndex
public int getTabIndex()Description copied from interface:Component.Focusable
Gets the tabulator index of theHasTabIndex
component.- Specified by:
getTabIndex
in interfaceComponent.Focusable
- Returns:
- tab index set for the
HasTabIndex
component
-
setTabIndex
public void setTabIndex(int tabIndex) Description copied from interface:Component.Focusable
Sets the tabulator index of theFocusable
component. The tab index property is used to specify the order in which the fields are focused when the user presses the Tab key. Components with a defined tab index are focused sequentially first, and then the components with no tab index.- Specified by:
setTabIndex
in interfaceComponent.Focusable
- Parameters:
tabIndex
- tab index
-
commit
public void commit()Description copied from interface:Buffered
Updates all changes since the previous commit to the data source.- Specified by:
commit
in interfaceBuffered
- Overrides:
commit
in classAbstractValueComponent<JmixTextField,
String, V>
-
discard
public void discard()Description copied from interface:Buffered
Discards all changes since last commit. The object updates its value from the data source.- Specified by:
discard
in interfaceBuffered
- Overrides:
discard
in classAbstractValueComponent<JmixTextField,
String, V>
-
isBuffered
public boolean isBuffered()- Specified by:
isBuffered
in interfaceBuffered
- Overrides:
isBuffered
in classAbstractValueComponent<JmixTextField,
String, V> - Returns:
true
if buffered mode is on,false
otherwise
-
setBuffered
public void setBuffered(boolean buffered) Description copied from interface:Buffered
Sets the buffered mode.When in buffered mode, an internal buffer will be used to store changes until
Buffered.commit()
is called. CallingBuffered.discard()
will revert the internal buffer to the value of the data source.When in non-buffered mode both read and write operations will be done directly on the data source. In this mode the
Buffered.commit()
andBuffered.discard()
methods serve no purpose.- Specified by:
setBuffered
in interfaceBuffered
- Overrides:
setBuffered
in classAbstractValueComponent<JmixTextField,
String, V> - Parameters:
buffered
-true
if buffered mode should be turned on,false
otherwise
-
isModified
public boolean isModified()Description copied from interface:Buffered
Tests if the value stored in the object has been modified since it was last updated from the data source.- Specified by:
isModified
in interfaceBuffered
- Overrides:
isModified
in classAbstractValueComponent<JmixTextField,
String, V> - Returns:
true
if the value in the object has been modified since the last data source update,false
if not.
-
setHtmlName
Description copied from interface:TextInputField.HtmlNameSupported
Sets the givenhtmlName
as a value of "name" HTML attribute.- Specified by:
setHtmlName
in interfaceTextInputField.HtmlNameSupported
- Parameters:
htmlName
- name
-
getHtmlName
- Specified by:
getHtmlName
in interfaceTextInputField.HtmlNameSupported
- Returns:
- a value of "name" HTML attribute
-