public abstract class AbstractTextField extends AbstractField<String> implements HasValueChangeMode, FieldEvents.FocusNotifier, FieldEvents.BlurNotifier
Component.ErrorEvent, Component.Event, Component.Focusable, Component.ListenerClientConnector.AttachEvent, ClientConnector.AttachListener, ClientConnector.ConnectorErrorEvent, ClientConnector.DetachEvent, ClientConnector.DetachListenerSizeable.UnitHasValue.ValueChangeEvent<V>, HasValue.ValueChangeListener<V>DESIGN_ATTR_PLAIN_TEXTSIZE_UNDEFINED, UNITS_CM, UNITS_EM, UNITS_EX, UNITS_INCH, UNITS_MM, UNITS_PERCENTAGE, UNITS_PICAS, UNITS_PIXELS, UNITS_POINTS| Modifier | Constructor and Description |
|---|---|
protected |
AbstractTextField()
Creates a new instance.
|
| Modifier and Type | Method and Description |
|---|---|
Registration |
addBlurListener(FieldEvents.BlurListener listener)
Adds a
FieldEvents.BlurListener to this component, which gets fired when this
component loses keyboard focus. |
Registration |
addFocusListener(FieldEvents.FocusListener listener)
Adds a
FieldEvents.FocusListener to this component, which gets fired when
this component receives keyboard focus. |
protected void |
doSetValue(String value)
Sets the value of this field.
|
int |
getCursorPosition()
Returns the last known cursor position of the field.
|
protected Collection<String> |
getCustomAttributes()
Returns a collection of attributes that should not be handled by the
basic implementation of the
AbstractComponent.readDesign(Element, DesignContext)
and AbstractComponent.writeDesign(Element, DesignContext) methods. |
String |
getEmptyValue()
Returns the value that represents an empty value.
|
int |
getMaxLength()
Returns the maximum number of characters in the field.
|
String |
getPlaceholder()
Returns the current placeholder text.
|
protected AbstractTextFieldState |
getState()
Returns the shared state bean with information to be sent from the server
to the client.
|
protected AbstractTextFieldState |
getState(boolean markAsDirty)
Returns the shared state for this connector.
|
String |
getValue()
Returns the current value of this object.
|
ValueChangeMode |
getValueChangeMode()
Returns the currently set
ValueChangeMode. |
int |
getValueChangeTimeout()
Returns the currently set timeout, in milliseconds, for how often
HasValue.ValueChangeEvents are triggered if the current
ValueChangeMode is set to either ValueChangeMode.LAZY or
ValueChangeMode.TIMEOUT. |
void |
readDesign(org.jsoup.nodes.Element design,
DesignContext designContext)
Reads the component state from the given design.
|
void |
selectAll()
Selects all text in the field.
|
void |
setCursorPosition(int pos)
Sets the cursor position in the field.
|
void |
setMaxLength(int maxLength)
Sets the maximum number of characters in the field.
|
void |
setPlaceholder(String placeholder)
Sets the placeholder text.
|
void |
setSelection(int start,
int length)
Sets the range of text to be selected.
|
void |
setValue(String value)
Sets the value of this text field.
|
void |
setValueChangeMode(ValueChangeMode mode)
Sets the mode how the TextField triggers
HasValue.ValueChangeEvents. |
void |
setValueChangeTimeout(int timeout)
Sets how often
HasValue.ValueChangeEvents are triggered when the
ValueChangeMode is set to either ValueChangeMode.LAZY or
ValueChangeMode.TIMEOUT. |
void |
writeDesign(org.jsoup.nodes.Element design,
DesignContext designContext)
Writes the component state to the given design.
|
addValueChangeListener, createValueChange, focus, getTabIndex, isDifferentValue, isReadOnly, isRequiredIndicatorVisible, setReadOnly, setRequiredIndicatorVisible, setTabIndex, setValueaddContextClickListener, addListener, addShortcutListener, addStyleName, attach, beforeClientResponse, detach, findAncestor, fireComponentErrorEvent, fireComponentEvent, getActionManager, getCaption, getComponentError, getData, getDebugId, getDescription, getErrorMessage, getHeight, getHeightUnits, getIcon, getId, getLocale, getParent, getPrimaryStyleName, getStyleName, getWidth, getWidthUnits, isCaptionAsHtml, isConnectorEnabled, isEnabled, isOrHasAncestor, isResponsive, isVisible, removeContextClickListener, removeListener, removeShortcutListener, removeStyleName, setCaption, setCaptionAsHtml, setComponentError, setData, setDebugId, setDescription, setDescription, setEnabled, setHeight, setHeight, setHeightUndefined, setIcon, setId, setLocale, setParent, setPrimaryStyleName, setResponsive, setSizeFull, setSizeUndefined, setStyleName, setVisible, setWidth, setWidth, setWidthUndefinedaddAttachListener, addDetachListener, addExtension, addListener, addListener, addListener, addMethodInvocationToQueue, createState, encodeState, equals, fireEvent, getAllChildrenIterable, getConnectorId, getErrorHandler, getExtensions, getListeners, getResource, getRpcManager, getRpcProxy, getSession, getStateType, getUI, handleConnectorRequest, hashCode, hasListeners, isAttached, isThis, markAsDirty, markAsDirtyRecursive, registerRpc, registerRpc, removeAttachListener, removeDetachListener, removeExtension, removeListener, removeListener, removeListener, removeListener, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandler, setResource, updateDiffstateclone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitaddListener, addStyleName, addStyleNames, attach, getCaption, getDescription, getIcon, getId, getLocale, getParent, getPrimaryStyleName, getStyleName, getUI, isEnabled, isVisible, removeListener, removeStyleName, removeStyleNames, setCaption, setEnabled, setIcon, setId, setParent, setPrimaryStyleName, setStyleName, setStyleName, setVisibleaddAttachListener, addDetachListener, beforeClientResponse, detach, encodeState, getErrorHandler, getExtensions, getRpcManager, getStateType, handleConnectorRequest, isAttached, isConnectorEnabled, markAsDirty, markAsDirtyRecursive, removeAttachListener, removeDetachListener, removeExtension, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandlergetConnectorIdgetHeight, getHeightUnits, getWidth, getWidthUnits, setHeight, setHeight, setHeightUndefined, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthUndefinedclear, getDefaultValidator, getOptionalValue, isEmptypublic void setValue(String value)
getValue(), fires a ValueChangeEvent. Throws
NullPointerException if the value is null.setValue in interface HasValue<String>setValue in class AbstractField<String>value - the new value, not nullNullPointerException - if value is nullpublic int getMaxLength()
public void setMaxLength(int maxLength)
maxLength - the maxLength to setpublic String getPlaceholder()
setPlaceholder(String)public void setPlaceholder(String placeholder)
placeholder - the placeholder text to setpublic String getValue()
HasValueImplementation note: the implementing class should document whether null values may be returned or not.
public void selectAll()
As a side effect the field will become focused.
public void setSelection(int start,
int length)
As a side effect the field will become focused.
start - the position of the first character to be selectedlength - the number of characters to be selectedpublic void setCursorPosition(int pos)
pos - the position for the cursorpublic int getCursorPosition()
public Registration addFocusListener(FieldEvents.FocusListener listener)
FieldEvents.FocusListener to this component, which gets fired when
this component receives keyboard focus.addFocusListener in interface FieldEvents.FocusNotifierlistener - the focus listenerRegistrationpublic Registration addBlurListener(FieldEvents.BlurListener listener)
FieldEvents.BlurListener to this component, which gets fired when this
component loses keyboard focus.addBlurListener in interface FieldEvents.BlurNotifierlistener - the blur listenerRegistrationpublic void setValueChangeMode(ValueChangeMode mode)
HasValueChangeModeHasValue.ValueChangeEvents.setValueChangeMode in interface HasValueChangeModemode - the new modeValueChangeModepublic ValueChangeMode getValueChangeMode()
HasValueChangeModeValueChangeMode.getValueChangeMode in interface HasValueChangeModeHasValue.ValueChangeEvents.ValueChangeModepublic void setValueChangeTimeout(int timeout)
HasValueChangeModeHasValue.ValueChangeEvents are triggered when the
ValueChangeMode is set to either ValueChangeMode.LAZY or
ValueChangeMode.TIMEOUT.setValueChangeTimeout in interface HasValueChangeModetimeout - timeout in milliseconds, must be greater or equal to 0ValueChangeModepublic int getValueChangeTimeout()
HasValueChangeModeHasValue.ValueChangeEvents are triggered if the current
ValueChangeMode is set to either ValueChangeMode.LAZY or
ValueChangeMode.TIMEOUT.getValueChangeTimeout in interface HasValueChangeModeHasValue.ValueChangeEvents are triggered.public void readDesign(org.jsoup.nodes.Element design,
DesignContext designContext)
ComponentThe component is responsible not only for updating its own state but also for ensuring that its children update their state based on the design.
It is assumed that the component is in its default state when this method is called. Reading should only take into consideration attributes specified in the design and not reset any unspecified attributes to their defaults.
This method must not modify the design.
readDesign in interface ComponentreadDesign in class AbstractField<String>design - The element to obtain the state fromdesignContext - The DesignContext instance used for parsing the designprotected AbstractTextFieldState getState()
AbstractComponentgetState in class AbstractField<String>protected AbstractTextFieldState getState(boolean markAsDirty)
AbstractClientConnectorgetState in class AbstractField<String>markAsDirty - true if the connector should automatically be marked dirty,
false otherwiseAbstractClientConnector.getState()protected void doSetValue(String value)
AbstractFieldIllegalArgumentException if the value is invalid. Typically saves
the value to shared state.doSetValue in class AbstractField<String>value - the new value of the fieldpublic void writeDesign(org.jsoup.nodes.Element design,
DesignContext designContext)
ComponentThe component is responsible not only for writing its own state but also for ensuring that its children write their state to the design.
This method must not modify the component state.
writeDesign in interface ComponentwriteDesign in class AbstractField<String>design - The element to write the component state to. Any previous
attributes or child nodes are not cleared.designContext - The DesignContext instance used for writing the designprotected Collection<String> getCustomAttributes()
AbstractComponentAbstractComponent.readDesign(Element, DesignContext)
and AbstractComponent.writeDesign(Element, DesignContext) methods. Typically these
are handled in a custom way in the overridden versions of the above
methodsgetCustomAttributes in class AbstractField<String>public String getEmptyValue()
HasValue
By default HasValue is expected to support null as empty
values. Specific implementations might not support this.
getEmptyValue in interface HasValue<String>Binder#bind(HasValue, ValueProvider, Setter)Copyright © 2018 Vaadin Ltd. All rights reserved.