public abstract class AbstractTextField extends AbstractField<String> implements FieldEvents.BlurNotifier, FieldEvents.FocusNotifier, FieldEvents.TextChangeNotifier, LegacyComponent
| Modifier and Type | Class and Description |
|---|---|
static class |
AbstractTextField.TextChangeEventImpl |
static class |
AbstractTextField.TextChangeEventMode
Different modes how the TextField can trigger
FieldEvents.TextChangeEvents. |
AbstractField.FocusShortcut, AbstractField.ReadOnlyStatusChangeEventComponent.ErrorEvent, Component.Event, Component.Focusable, Component.ListenerClientConnector.AttachEvent, ClientConnector.AttachListener, ClientConnector.ConnectorErrorEvent, ClientConnector.DetachEvent, ClientConnector.DetachListenerSizeable.UnitField.ValueChangeEventBuffered.SourceExceptionProperty.Editor, Property.ReadOnlyException, Property.ReadOnlyStatusChangeListener, Property.ReadOnlyStatusChangeNotifier, Property.Transactional<T>, Property.ValueChangeListener, Property.ValueChangeNotifier, Property.ViewerDESIGN_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() |
| Modifier and Type | Method and Description |
|---|---|
void |
addBlurListener(FieldEvents.BlurListener listener)
Adds a
BlurListener to the Component which gets fired
when a Field loses keyboard focus. |
void |
addFocusListener(FieldEvents.FocusListener listener)
Adds a
FocusListener to the Component which gets fired
when a Field receives keyboard focus. |
void |
addListener(FieldEvents.BlurListener listener)
Deprecated.
As of 7.0, replaced by
#addBlurListener(BlurListener) |
void |
addListener(FieldEvents.FocusListener listener)
Deprecated.
As of 7.0, replaced by
#addFocusListener(FocusListener) |
void |
addListener(FieldEvents.TextChangeListener listener)
Deprecated.
As of 7.0, replaced by
#addTextChangeListener(TextChangeListener) |
void |
addTextChangeListener(FieldEvents.TextChangeListener listener) |
void |
beforeClientResponse(boolean initial)
Called before the shared state and RPC invocations are sent to the
client.
|
void |
changeVariables(Object source,
Map<String,Object> variables)
Called when one or more variables handled by the implementing class are
changed.
|
int |
getColumns()
Gets the number of columns in the editor.
|
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
readDesign and writeDesign
methods. |
String |
getInputPrompt()
Gets the current input prompt.
|
int |
getMaxLength()
Returns the maximum number of characters in the field.
|
String |
getNullRepresentation()
Gets the null-string representation.
|
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.
|
AbstractTextField.TextChangeEventMode |
getTextChangeEventMode() |
int |
getTextChangeTimeout()
Gets the timeout used to fire
FieldEvents.TextChangeEvents when the
getTextChangeEventMode() is AbstractTextField.TextChangeEventMode.LAZY or
AbstractTextField.TextChangeEventMode.TIMEOUT. |
Class<String> |
getType()
Returns the type of the Field.
|
boolean |
isEmpty()
Is the field empty?
In general, "empty" state is same as null.
|
boolean |
isNullSettingAllowed()
Is setting nulls with null-string representation allowed.
|
void |
paintContent(PaintTarget target)
Paints the Paintable into a UIDL stream.
|
void |
readDesign(org.jsoup.nodes.Element design,
DesignContext designContext)
Reads the component state from the given design.
|
void |
removeBlurListener(FieldEvents.BlurListener listener)
Removes a
BlurListener from the Component. |
void |
removeFocusListener(FieldEvents.FocusListener listener)
Removes a
FocusListener from the Component. |
void |
removeListener(FieldEvents.BlurListener listener)
Deprecated.
As of 7.0, replaced by
#removeBlurListener(BlurListener) |
void |
removeListener(FieldEvents.FocusListener listener)
Deprecated.
As of 7.0, replaced by
#removeFocusListener(FocusListener) |
void |
removeListener(FieldEvents.TextChangeListener listener)
Deprecated.
As of 7.0, replaced by
#removeTextChangeListener(TextChangeListener) |
void |
removeTextChangeListener(FieldEvents.TextChangeListener listener) |
void |
selectAll()
Selects all text in the field.
|
void |
setColumns(int columns)
Sets the number of columns in the editor.
|
void |
setCursorPosition(int pos)
Sets the cursor position in the field.
|
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.
|
protected void |
setInternalValue(String newValue)
Sets the internal field value.
|
void |
setMaxLength(int maxLength)
Sets the maximum number of characters in the field.
|
void |
setNullRepresentation(String nullRepresentation)
Sets the null-string representation.
|
void |
setNullSettingAllowed(boolean nullSettingAllowed)
Sets the null conversion mode.
|
void |
setSelectionRange(int pos,
int length)
Sets the range of text to be selected.
|
void |
setTextChangeEventMode(AbstractTextField.TextChangeEventMode inputEventMode)
Sets the mode how the TextField triggers
FieldEvents.TextChangeEvents. |
void |
setTextChangeTimeout(int timeout)
The text change timeout modifies how often text change events are
communicated to the application when
getTextChangeEventMode() is
AbstractTextField.TextChangeEventMode.LAZY or AbstractTextField.TextChangeEventMode.TIMEOUT. |
void |
setValue(String newValue)
Sets the value of the field.
|
void |
writeDesign(org.jsoup.nodes.Element design,
DesignContext designContext)
Writes the component state to the given design.
|
addListener, addListener, addReadOnlyStatusChangeListener, addValidator, addValueChangeListener, attach, clear, commit, detach, discard, fireReadOnlyStatusChange, fireValueChange, focus, getConversionError, getConversionError, getConvertedValue, getConverter, getCurrentBufferedSourceException, getErrorMessage, getInternalValue, getModelType, getPropertyDataSource, getRequiredError, getTabIndex, getValidators, getValue, isBuffered, isImmediate, isInvalidAllowed, isInvalidCommitted, isModified, isReadOnly, isRequired, isValid, isValidationVisible, readOnlyStatusChange, removeAllValidators, removeListener, removeListener, removeReadOnlyStatusChangeListener, removeValidator, removeValueChangeListener, setBuffered, setConversionError, setConvertedValue, setConverter, setConverter, setCurrentBufferedSourceException, setInvalidAllowed, setInvalidCommitted, setLocale, setPropertyDataSource, setReadOnly, setRequired, setRequiredError, setTabIndex, setValidationVisible, setValue, setValue, shouldHideErrors, toString, validate, validate, valueChangeaddContextClickListener, addListener, addShortcutListener, addStyleName, findAncestor, fireComponentErrorEvent, fireComponentEvent, getActionManager, getCaption, getComponentError, getData, getDebugId, getDescription, getExplicitImmediateValue, 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, setEnabled, setHeight, setHeight, setHeightUndefined, setIcon, setId, setImmediate, setParent, setPrimaryStyleName, setResponsive, setSizeFull, setSizeUndefined, setStyleName, 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, setResourceclone, finalize, getClass, notify, notifyAll, wait, wait, waitmarkAsDirtyisEnabled, isImmediateaddListener, addStyleName, attach, getCaption, getDescription, getIcon, getId, getLocale, getParent, getPrimaryStyleName, getStyleName, getUI, isEnabled, isReadOnly, isVisible, removeListener, removeStyleName, setCaption, setEnabled, setIcon, setId, setParent, setPrimaryStyleName, setReadOnly, setStyleName, setVisibleaddAttachListener, addDetachListener, detach, encodeState, getErrorHandler, getExtensions, getRpcManager, getStateType, handleConnectorRequest, isAttached, isConnectorEnabled, markAsDirtyRecursive, removeAttachListener, removeDetachListener, removeExtension, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandlergetConnectorIdgetHeight, getHeightUnits, getWidth, getWidthUnits, setHeight, setHeight, setHeightUndefined, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthUndefinedaddShortcutListener, removeShortcutListenerprotected 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()public void beforeClientResponse(boolean initial)
ClientConnectorbeforeClientResponse in interface ClientConnectorbeforeClientResponse in class AbstractField<String>initial - true if the client-side connector will be created
and initialized after this method has been invoked.
false if there is already an initialized
client-side connector.public void paintContent(PaintTarget target) throws PaintException
LegacyComponentPaints the Paintable into a UIDL stream. This method creates the UIDL sequence describing it and outputs it to the given UIDL stream.
It is called when the contents of the component should be painted in response to the component first being shown or having been altered so that its visual representation is changed.
paintContent in interface LegacyComponenttarget - the target UIDL stream where the component should paint itself
to.PaintException - if the paint operation failed.public void changeVariables(Object source, Map<String,Object> variables)
VariableOwnerchangeVariables in interface VariableOwnersource - the Source of the variable change. This is the origin of the
event. For example in Web Adapter this is the request.variables - the Mapping from variable names to new variable values.public Class<String> getType()
AbstractFieldgetValue and
setValue must be compatible with this type: one must be able
to safely cast the value returned from getValue to the given
type and pass any variable assignable to this type as an argument to
setValue.public String getNullRepresentation()
The null-valued strings are represented on the user interface by replacing the null value with this string. If the null representation is set null (not 'null' string), painting null value throws exception.
The default value is string 'null'.
isNullSettingAllowed()public boolean isNullSettingAllowed()
If this property is true, writing null-representation string to text field always sets the field value to real null. If this property is false, null setting is not made, but the null values are maintained. Maintenance of null-values is made by only converting the textfield contents to real null, if the text field matches the null-string representation and the current value of the field is null.
By default this setting is false
getNullRepresentation()public void setNullRepresentation(String nullRepresentation)
The null-valued strings are represented on the user interface by replacing the null value with this string. If the null representation is set null (not 'null' string), painting null value throws exception.
The default value is string 'null'
nullRepresentation - Textual representation for null strings.setNullSettingAllowed(boolean)public void setNullSettingAllowed(boolean nullSettingAllowed)
If this property is true, writing null-representation string to text field always sets the field value to real null. If this property is false, null setting is not made, but the null values are maintained. Maintenance of null-values is made by only converting the textfield contents to real null, if the text field matches the null-string representation and the current value of the field is null.
By default this setting is false.
nullSettingAllowed - Should the null-string representation always be converted to
null-values.getNullRepresentation()public boolean isEmpty()
Fieldpublic int getMaxLength()
public void setMaxLength(int maxLength)
maxLength - the maxLength to setpublic int getColumns()
public void setColumns(int columns)
columns - the number of columns to set.public String getInputPrompt()
setInputPrompt(String)public void setInputPrompt(String inputPrompt)
inputPrompt - protected void setInternalValue(String newValue)
AbstractFieldAbstractField.getInternalValue() if necessary.setInternalValue in class AbstractField<String>newValue - the new value to be set.public void setValue(String newValue) throws Property.ReadOnlyException
AbstractFieldsetValue in interface Property<String>setValue in class AbstractField<String>newValue - the New value of the field.Property.ReadOnlyException - if the object is in read-only modepublic void setTextChangeEventMode(AbstractTextField.TextChangeEventMode inputEventMode)
FieldEvents.TextChangeEvents.inputEventMode - the new modeAbstractTextField.TextChangeEventModepublic AbstractTextField.TextChangeEventMode getTextChangeEventMode()
FieldEvents.TextChangeEvents.public void addTextChangeListener(FieldEvents.TextChangeListener listener)
addTextChangeListener in interface FieldEvents.TextChangeNotifier@Deprecated public void addListener(FieldEvents.TextChangeListener listener)
#addTextChangeListener(TextChangeListener)addListener in interface FieldEvents.TextChangeNotifierpublic void removeTextChangeListener(FieldEvents.TextChangeListener listener)
removeTextChangeListener in interface FieldEvents.TextChangeNotifier@Deprecated public void removeListener(FieldEvents.TextChangeListener listener)
#removeTextChangeListener(TextChangeListener)removeListener in interface FieldEvents.TextChangeNotifierpublic void setTextChangeTimeout(int timeout)
getTextChangeEventMode() is
AbstractTextField.TextChangeEventMode.LAZY or AbstractTextField.TextChangeEventMode.TIMEOUT.timeout - the timeout in millisecondsgetTextChangeEventMode()public int getTextChangeTimeout()
FieldEvents.TextChangeEvents when the
getTextChangeEventMode() is AbstractTextField.TextChangeEventMode.LAZY or
AbstractTextField.TextChangeEventMode.TIMEOUT.public void selectAll()
public void setSelectionRange(int pos,
int length)
pos - 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()
Note that due to the client server nature or the GWT terminal, Vaadin
cannot provide the exact value of the cursor position in most situations.
The value is updated only when the client side terminal communicates to
TextField, like on ValueChangeEvents and FieldEvents.TextChangeEvent
s. This may change later if a deep push integration is built to Vaadin.
public void addFocusListener(FieldEvents.FocusListener listener)
FieldEvents.FocusNotifierFocusListener to the Component which gets fired
when a Field receives keyboard focus.addFocusListener in interface FieldEvents.FocusNotifierFieldEvents.FocusListener@Deprecated public void addListener(FieldEvents.FocusListener listener)
#addFocusListener(FocusListener)addListener in interface FieldEvents.FocusNotifierpublic void removeFocusListener(FieldEvents.FocusListener listener)
FieldEvents.FocusNotifierFocusListener from the Component.removeFocusListener in interface FieldEvents.FocusNotifierFieldEvents.FocusListener@Deprecated public void removeListener(FieldEvents.FocusListener listener)
#removeFocusListener(FocusListener)removeListener in interface FieldEvents.FocusNotifierpublic void addBlurListener(FieldEvents.BlurListener listener)
FieldEvents.BlurNotifierBlurListener to the Component which gets fired
when a Field loses keyboard focus.addBlurListener in interface FieldEvents.BlurNotifierFieldEvents.BlurListener@Deprecated public void addListener(FieldEvents.BlurListener listener)
#addBlurListener(BlurListener)addListener in interface FieldEvents.BlurNotifierpublic void removeBlurListener(FieldEvents.BlurListener listener)
FieldEvents.BlurNotifierBlurListener from the Component.removeBlurListener in interface FieldEvents.BlurNotifierFieldEvents.BlurListener@Deprecated public void removeListener(FieldEvents.BlurListener listener)
#removeBlurListener(BlurListener)removeListener in interface FieldEvents.BlurNotifierpublic 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 Collection<String> getCustomAttributes()
AbstractComponentreadDesign and writeDesign
methods. Typically these are handled in a custom way in the overridden
versions of the above methodsgetCustomAttributes in class AbstractField<String>public 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 designCopyright © 2019 Vaadin Ltd. All rights reserved.