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.WrapperNested classes/interfaces inherited from interface io.jmix.ui.component.HasContextHelp
HasContextHelp.ContextHelpIconClickEventNested 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
FieldsModifier and TypeFieldDescriptionprotected Stringprotected DataAwareComponentsToolsprotected com.vaadin.shared.Registrationprotected Localeprotected booleanFields inherited from class io.jmix.ui.component.impl.AbstractField
editable, parentEditableChangeListener, validators, VALIDATORS_LIST_INITIAL_CAPACITYFields inherited from class io.jmix.ui.component.impl.AbstractValueComponent
internalValue, uiTestIdsSupport, valueBindingFields inherited from class io.jmix.ui.component.impl.AbstractComponent
alignment, applicationContext, component, contextHelpIconClickHandler, contextHelpIconClickListener, descriptionAsHtml, element, frame, htmlSanitizerEnabled, icon, ICON_STYLE, id, parentFields inherited from interface io.jmix.ui.component.Component
AUTO_SIZE, AUTO_SIZE_PX, FULL_SIZEFields 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
Constructors -
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.voidvoidcommit()Updates all changes since the previous commit to the data source.protected voidcomponentValueChanged(String prevComponentValue, String newComponentValue, boolean isUserOriginated) protected VconvertToModel(String componentRawValue) protected StringconvertToPresentation(V modelValue) protected JmixTextFieldvoiddiscard()Discards all changes since last commit.protected voidfireTextChangeEvent(String newComponentValue) voidfocus()Sets focus to this componentprotected StringintReturns a string representation of the value.intGets the tabulator index of theHasTabIndexcomponent.intGets the timeout used to fireTextInputField.TextChangeEvents andHasValue.ValueChangeEvents when theTextInputField.TextChangeNotifier.getTextChangeEventMode()isTextInputField.TextChangeEventMode.LAZYorTextInputField.TextChangeEventMode.TIMEOUT.protected voidinitComponent(JmixTextField component) protected voidbooleanbooleanisEmpty()booleanTests if the value stored in the object has been modified since it was last updated from the data source.booleanvoidvoidsetBuffered(boolean buffered) Sets the buffered mode.voidsetCaseConversion(TextInputField.CaseConversion caseConversion) Disable automatic case conversion or enable with chosen modevoidsetConversionErrorMessage(String conversionErrorMessage) Sets custom conversion error message that is used when value doesn't correspond to datatype.voidsetCurrentAuthentication(CurrentAuthentication currentAuthentication) voidsetCursorPosition(int position) Sets the cursor position in the field.voidsetDataAwareComponentsTools(DataAwareComponentsTools dataAwareComponentsTools) voidsetDatatype(Datatype<V> datatype) Sets the givendatatypeto the component.voidsetFormatter(Formatter<? super V> formatter) voidsetHtmlName(String htmlName) Sets the givenhtmlNameas a value of "name" HTML attribute.voidsetInputPrompt(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.voidsetMaxLength(int maxLength) voidsetSelectionRange(int pos, int length) voidsetTabIndex(int tabIndex) Sets the tabulator index of theFocusablecomponent.voidSets the mode how the TextField triggersTextInputField.TextChangeEvents andHasValue.ValueChangeEvents.voidsetTextChangeTimeout(int timeout) The text change timeout modifies how often text change events are communicated to the application whenTextInputField.TextChangeNotifier.getTextChangeEventMode()isTextInputField.TextChangeEventMode.LAZYorTextInputField.TextChangeEventMode.TIMEOUT.voidsetTrimming(boolean trimming) protected voidvalueBindingConnected(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, validateMethods inherited from class io.jmix.ui.component.impl.AbstractValueComponent
addValueChangeListener, fieldValueEquals, getValue, getValueSource, setUiTestId, setUiTestIdsSupport, setValue, setValueSource, setValueToPresentation, valueBindingActivatedMethods 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, withUnwrappedCompositionMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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, withUnwrappedCompositionMethods inherited from interface io.jmix.ui.component.Component.BelongToFrame
getFrame, setFrameMethods inherited from interface io.jmix.ui.component.Component.Editable
isEditable, isEditableWithParent, setEditableMethods inherited from interface io.jmix.ui.component.Component.Focusable
isFocusable, setFocusableMethods inherited from interface io.jmix.ui.component.Component.HasCaption
getCaption, setCaptionMethods inherited from interface io.jmix.ui.component.Component.HasDescription
getDescription, setDescriptionMethods inherited from interface io.jmix.ui.component.Component.HasIcon
getIcon, setIcon, setIconFromSetMethods inherited from interface io.jmix.ui.component.HasContextHelp
getContextHelpIconClickHandler, getContextHelpText, isContextHelpTextHtmlEnabled, setContextHelpIconClickHandler, setContextHelpText, setContextHelpTextHtmlEnabledMethods inherited from interface io.jmix.ui.component.HasHtmlCaption
isCaptionAsHtml, setCaptionAsHtmlMethods inherited from interface io.jmix.ui.component.HasHtmlDescription
isDescriptionAsHtml, setDescriptionAsHtmlMethods inherited from interface io.jmix.ui.component.HasHtmlSanitizer
isHtmlSanitizerEnabled, setHtmlSanitizerEnabledMethods inherited from interface io.jmix.ui.component.HasValidator
addValidator, addValidators, getValidators, removeValidatorMethods inherited from interface io.jmix.ui.component.HasValue
addValueChangeListener, clear, getEmptyValue, getValue, setValueMethods inherited from interface io.jmix.ui.component.data.HasValueSource
getValueSource, setValueSourceMethods inherited from interface io.jmix.ui.component.Requirable
getRequiredMessage, isRequired, setRequired, setRequiredMessageMethods 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:
afterPropertiesSetin interfaceorg.springframework.beans.factory.InitializingBean
-
initComponent
-
valueBindingConnected
- Overrides:
valueBindingConnectedin classAbstractValueComponent<JmixTextField,String, V>
-
convertToPresentation
- Overrides:
convertToPresentationin classAbstractValueComponent<JmixTextField,String, V> - Throws:
ConversionException
-
convertToModel
- Overrides:
convertToModelin classAbstractValueComponent<JmixTextField,String, V> - Throws:
ConversionException
-
setConversionErrorMessage
Description copied from interface:HasConversionErrorMessageSets custom conversion error message that is used when value doesn't correspond to datatype.- Specified by:
setConversionErrorMessagein interfaceHasConversionErrorMessage- Parameters:
conversionErrorMessage- custom conversion error message
-
getConversionErrorMessage
- Specified by:
getConversionErrorMessagein interfaceHasConversionErrorMessage- Returns:
- custom conversion error message
-
getConversionErrorMessageInternal
-
componentValueChanged
protected void componentValueChanged(String prevComponentValue, String newComponentValue, boolean isUserOriginated) - Overrides:
componentValueChangedin classAbstractValueComponent<JmixTextField,String, V>
-
isEmpty
public boolean isEmpty() -
getDatatype
- Specified by:
getDatatypein interfaceHasDatatype<V>- Returns:
- a datatype that is used by this component
-
setDatatype
Description copied from interface:HasDatatypeSets the givendatatypeto the component. Its value will be formatted according to this datatype.- Specified by:
setDatatypein interfaceHasDatatype<V>- Parameters:
datatype-Datatypeinstance
-
getCaseConversion
- Specified by:
getCaseConversionin interfaceTextInputField.CaseConversionSupported- Returns:
- conversion mode or null if automatic conversion is disabled
-
setCaseConversion
Description copied from interface:TextInputField.CaseConversionSupportedDisable automatic case conversion or enable with chosen mode- Specified by:
setCaseConversionin interfaceTextInputField.CaseConversionSupported
-
getFormatter
- Specified by:
getFormatterin interfaceHasFormatter<V>
-
setFormatter
- Specified by:
setFormatterin interfaceHasFormatter<V>
-
getMaxLength
public int getMaxLength()- Specified by:
getMaxLengthin interfaceTextInputField.MaxLengthLimited
-
setMaxLength
public void setMaxLength(int maxLength) - Specified by:
setMaxLengthin interfaceTextInputField.MaxLengthLimited
-
isTrimming
public boolean isTrimming()- Specified by:
isTrimmingin interfaceTextInputField.TrimSupported
-
setTrimming
public void setTrimming(boolean trimming) - Specified by:
setTrimmingin interfaceTextInputField.TrimSupported
-
getInputPrompt
- Specified by:
getInputPromptin interfaceHasInputPrompt- Returns:
- current input prompt.
-
setInputPrompt
Description copied from interface:HasInputPromptSets the input prompt - a textual prompt that is displayed when the field would otherwise be empty, to prompt the user for input.- Specified by:
setInputPromptin interfaceHasInputPrompt- Parameters:
inputPrompt- input prompt
-
setCursorPosition
public void setCursorPosition(int position) Description copied from interface:TextInputField.CursorPositionSupportedSets the cursor position in the field.- Specified by:
setCursorPositionin interfaceTextInputField.CursorPositionSupported- Parameters:
position- new cursor position
-
getRawValue
Description copied from interface:TextFieldReturns a string representation of the value.- Specified by:
getRawValuein interfaceTextField<V>
-
selectAll
public void selectAll()- Specified by:
selectAllin interfaceTextInputField.TextSelectionSupported
-
setSelectionRange
public void setSelectionRange(int pos, int length) - Specified by:
setSelectionRangein interfaceTextInputField.TextSelectionSupported
-
fireTextChangeEvent
-
setTextChangeTimeout
public void setTextChangeTimeout(int timeout) Description copied from interface:TextInputField.TextChangeNotifierThe text change timeout modifies how often text change events are communicated to the application whenTextInputField.TextChangeNotifier.getTextChangeEventMode()isTextInputField.TextChangeEventMode.LAZYorTextInputField.TextChangeEventMode.TIMEOUT.- Specified by:
setTextChangeTimeoutin interfaceTextInputField.TextChangeNotifier- Parameters:
timeout- timeout in milliseconds
-
addTextChangeListener
Description copied from interface:TextInputField.TextChangeNotifierAdds a listener that is fired when the component value is changed.- Specified by:
addTextChangeListenerin interfaceTextInputField.TextChangeNotifier- Parameters:
listener- a listener to add- Returns:
- a
Subscriptionobject
-
getTextChangeTimeout
public int getTextChangeTimeout()Description copied from interface:TextInputField.TextChangeNotifierGets the timeout used to fireTextInputField.TextChangeEvents andHasValue.ValueChangeEvents when theTextInputField.TextChangeNotifier.getTextChangeEventMode()isTextInputField.TextChangeEventMode.LAZYorTextInputField.TextChangeEventMode.TIMEOUT.- Specified by:
getTextChangeTimeoutin interfaceTextInputField.TextChangeNotifier- Returns:
- timeout in milliseconds
-
getTextChangeEventMode
- Specified by:
getTextChangeEventModein interfaceTextInputField.TextChangeNotifier- Returns:
- the mode used to trigger
TextInputField.TextChangeEvents andHasValue.ValueChangeEvents.
-
setTextChangeEventMode
Description copied from interface:TextInputField.TextChangeNotifierSets the mode how the TextField triggersTextInputField.TextChangeEvents andHasValue.ValueChangeEvents.- Specified by:
setTextChangeEventModein interfaceTextInputField.TextChangeNotifier- Parameters:
mode- the new mode
-
addEnterPressListener
Description copied from interface:TextInputField.EnterPressNotifierAdds a listener that is invoked when the user presses Enter.- Specified by:
addEnterPressListenerin interfaceTextInputField.EnterPressNotifier- Parameters:
listener- a listener to add- Returns:
- a
Subscription
-
internalRemoveEnterPressListener
-
focus
public void focus()Description copied from interface:Component.FocusableSets focus to this component- Specified by:
focusin interfaceComponent.Focusable
-
getTabIndex
public int getTabIndex()Description copied from interface:Component.FocusableGets the tabulator index of theHasTabIndexcomponent.- Specified by:
getTabIndexin interfaceComponent.Focusable- Returns:
- tab index set for the
HasTabIndexcomponent
-
setTabIndex
public void setTabIndex(int tabIndex) Description copied from interface:Component.FocusableSets the tabulator index of theFocusablecomponent. 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:
setTabIndexin interfaceComponent.Focusable- Parameters:
tabIndex- tab index
-
commit
public void commit()Description copied from interface:BufferedUpdates all changes since the previous commit to the data source.- Specified by:
commitin interfaceBuffered- Overrides:
commitin classAbstractValueComponent<JmixTextField,String, V>
-
discard
public void discard()Description copied from interface:BufferedDiscards all changes since last commit. The object updates its value from the data source.- Specified by:
discardin interfaceBuffered- Overrides:
discardin classAbstractValueComponent<JmixTextField,String, V>
-
isBuffered
public boolean isBuffered()- Specified by:
isBufferedin interfaceBuffered- Overrides:
isBufferedin classAbstractValueComponent<JmixTextField,String, V> - Returns:
trueif buffered mode is on,falseotherwise
-
setBuffered
public void setBuffered(boolean buffered) Description copied from interface:BufferedSets 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:
setBufferedin interfaceBuffered- Overrides:
setBufferedin classAbstractValueComponent<JmixTextField,String, V> - Parameters:
buffered-trueif buffered mode should be turned on,falseotherwise
-
isModified
public boolean isModified()Description copied from interface:BufferedTests if the value stored in the object has been modified since it was last updated from the data source.- Specified by:
isModifiedin interfaceBuffered- Overrides:
isModifiedin classAbstractValueComponent<JmixTextField,String, V> - Returns:
trueif the value in the object has been modified since the last data source update,falseif not.
-
setHtmlName
Description copied from interface:TextInputField.HtmlNameSupportedSets the givenhtmlNameas a value of "name" HTML attribute.- Specified by:
setHtmlNamein interfaceTextInputField.HtmlNameSupported- Parameters:
htmlName- name
-
getHtmlName
- Specified by:
getHtmlNamein interfaceTextInputField.HtmlNameSupported- Returns:
- a value of "name" HTML attribute
-