com.vaadin.ui.


Class TextField

java.lang.Object
  com.vaadin.ui.AbstractComponent
      com.vaadin.ui.AbstractField
          com.vaadin.ui.AbstractTextField
              com.vaadin.ui.TextField

All Implemented Interfaces:

Buffered, BufferedValidatable, Property, Property.Editor, Property.ReadOnlyStatusChangeListener, Property.ReadOnlyStatusChangeNotifier, Property.ValueChangeListener, Property.ValueChangeNotifier, Property.Viewer, Validatable, Action.ShortcutNotifier, FieldEvents.BlurNotifier, FieldEvents.FocusNotifier, FieldEvents.TextChangeNotifier, MethodEventSource, Paintable, Sizeable, VariableOwner, Component, Component.Focusable, Field, Serializable, EventListener

public class TextField
extends AbstractTextField

A text editor component that can be bound to any bindable Property. The text editor supports both multiline and single line modes, default is one-line mode.

Since TextField extends AbstractField it implements the Buffered interface. A TextField is in write-through mode by default, so AbstractField.setWriteThrough(boolean) must be called to enable buffering.

Since:

3.0

Version:

6.8.18

Author:

Vaadin Ltd.

See Also:

Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class com.vaadin.ui.AbstractTextField
AbstractTextField.TextChangeEventImpl, AbstractTextField.TextChangeEventMode
 
Nested classes/interfaces inherited from class com.vaadin.ui.AbstractField
AbstractField.FocusShortcut, AbstractField.ReadOnlyStatusChangeEvent
 
Nested classes/interfaces inherited from class com.vaadin.ui.AbstractComponent
AbstractComponent.ComponentErrorEvent, AbstractComponent.ComponentErrorHandler
 
Nested classes/interfaces inherited from interface com.vaadin.ui.Field
Field.ValueChangeEvent
 
Nested classes/interfaces inherited from interface com.vaadin.data.Buffered
Buffered.SourceException
 
Nested classes/interfaces inherited from interface com.vaadin.data.Property
Property.ConversionException, Property.Editor, Property.ReadOnlyException, Property.ReadOnlyStatusChangeListener, Property.ReadOnlyStatusChangeNotifier, Property.ValueChangeListener, Property.ValueChangeNotifier, Property.Viewer
 
Constructor Summary
TextField()
          Constructs an empty TextField with no caption.
TextField(Property dataSource)
          Constructs a new TextField that's bound to the specified Property and has no caption.
TextField(String caption)
          Constructs an empty TextField with given caption.
TextField(String caption, Property dataSource)
          Constructs a new TextField that's bound to the specified Property and has the given caption String.
TextField(String caption, String value)
          Constructs a new TextField with the given caption and initial text contents.
 
Method Summary
 int getRows()
          Deprecated. Starting from 6.5 use TextArea for a multi-line text input.
 boolean isSecret()
          Deprecated. Starting from 6.5 use PasswordField instead for secret text input.
 boolean isWordwrap()
          Deprecated. Starting from 6.5 use TextArea for a multi-line text input.
 void paintContent(PaintTarget target)
          Paints any needed component-specific things to the given UIDL stream.
 void setHeight(float height, int unit)
          Sets the height of the TextField instance.
 void setHeight(String height)
          Sets the height of the TextField instance.
 void setRows(int rows)
          Deprecated. Starting from 6.5 use TextArea for a multi-line text input.
 void setSecret(boolean secret)
          Deprecated. Starting from 6.5 use PasswordField instead for secret text input.
 void setWordwrap(boolean wordwrap)
          Deprecated. Starting from 6.5 use TextArea for a multi-line text input.
 
Methods inherited from class com.vaadin.ui.AbstractTextField
addListener, addListener, addListener, changeVariables, getColumns, getCursorPosition, getFormat, getFormattedValue, getInputPrompt, getMaxLength, getNullRepresentation, getTextChangeEventMode, getTextChangeTimeout, getType, getValue, isEmpty, isNullSettingAllowed, removeListener, removeListener, removeListener, selectAll, setColumns, setCursorPosition, setFormat, setInputPrompt, setInternalValue, setMaxLength, setNullRepresentation, setNullSettingAllowed, setSelectionRange, setTextChangeEventMode, setTextChangeTimeout, setValue
 
Methods inherited from class com.vaadin.ui.AbstractField
addListener, addListener, addShortcutListener, addValidator, attach, commit, constructField, detach, discard, fireReadOnlyStatusChange, fireValueChange, focus, getActionManager, getErrorMessage, getPropertyDataSource, getRequiredError, getTabIndex, getValidators, isInvalidAllowed, isInvalidCommitted, isModified, isReadOnly, isReadThrough, isRequired, isValid, isValidationVisible, isWriteThrough, readOnlyStatusChange, removeAllValidators, removeListener, removeListener, removeShortcutListener, removeValidator, setCurrentBufferedSourceException, setInvalidAllowed, setInvalidCommitted, setPropertyDataSource, setReadOnly, setReadThrough, setRequired, setRequiredError, setTabIndex, setValidationVisible, setValue, setWriteThrough, shouldHideErrors, toString, validate, valueChange
 
Methods inherited from class com.vaadin.ui.AbstractComponent
addListener, addListener, addListener, addListener, addListener, addStyleName, childRequestedRepaint, fireComponentErrorEvent, fireComponentEvent, fireEvent, getApplication, getCaption, getComponentError, getData, getDebugId, getDescription, getErrorHandler, getHeight, getHeightUnits, getIcon, getListeners, getLocale, getParent, getStyle, getStyleName, getWidth, getWidthUnits, getWindow, handleError, hasListeners, isEnabled, isImmediate, isVisible, paint, removeListener, removeListener, removeListener, removeListener, removeListener, removeListener, removeStyleName, requestRepaint, requestRepaintRequests, setCaption, setComponentError, setData, setDebugId, setDescription, setEnabled, setErrorHandler, setHeight, setHeightUnits, setIcon, setImmediate, setLocale, setParent, setSizeFull, setSizeUndefined, setStyle, setStyleName, setVisible, setWidth, setWidth, setWidth, setWidthUnits
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.vaadin.ui.Field
getDescription, setCaption, setDescription
 

Constructor Detail

TextField

public TextField()

Constructs an empty TextField with no caption.

TextField

public TextField(String caption)

Constructs an empty TextField with given caption.

Parameters:
caption - the caption String for the editor.

TextField

public TextField(Property dataSource)

Constructs a new TextField that's bound to the specified Property and has no caption.

Parameters:
dataSource - the Property to be edited with this editor.

TextField

public TextField(String caption,
                 Property dataSource)

Constructs a new TextField that's bound to the specified Property and has the given caption String.

Parameters:
caption - the caption String for the editor.
dataSource - the Property to be edited with this editor.

TextField

public TextField(String caption,
                 String value)

Constructs a new TextField with the given caption and initial text contents. The editor constructed this way will not be bound to a Property unless Property.Viewer.setPropertyDataSource(Property) is called to bind it.

Parameters:
caption - the caption String for the editor.
text - the initial text content of the editor.

Method Detail

isSecret

@Deprecated
public boolean isSecret()

Deprecated. Starting from 6.5 use PasswordField instead for secret text input.

Gets the secret property. If a field is used to enter secret information the information is not echoed to display.

Returns:
true if the field is used to enter secret information, false otherwise.

setSecret

@Deprecated
public void setSecret(boolean secret)

Deprecated. Starting from 6.5 use PasswordField instead for secret text input.

Sets the secret property on and off. If a field is used to enter secret information the information is not echoed to display.

Parameters:
secret - the value specifying if the field is used to enter secret information.

paintContent

public void paintContent(PaintTarget target)
                  throws PaintException

Description copied from class: AbstractComponent

Paints any needed component-specific things to the given UIDL stream. The more general AbstractComponent.paint(PaintTarget) method handles all general attributes common to all components, and it calls this method to paint any component-specific attributes to the UIDL stream.

Overrides:
paintContent in class AbstractTextField

Parameters:
target - the target UIDL stream where the component should paint itself to
Throws:
PaintException - if the paint operation failed.

getRows

@Deprecated
public int getRows()

Deprecated. Starting from 6.5 use TextArea for a multi-line text input.

Gets the number of rows in the editor. If the number of rows is set to 0, the actual number of displayed rows is determined implicitly by the adapter.

Returns:
number of explicitly set rows.

setRows

@Deprecated
public void setRows(int rows)

Deprecated. Starting from 6.5 use TextArea for a multi-line text input.

Sets the number of rows in the editor.

Parameters:
rows - the number of rows for this editor.

isWordwrap

@Deprecated
public boolean isWordwrap()

Deprecated. Starting from 6.5 use TextArea for a multi-line text input.

Tests if the editor is in word-wrap mode.

Returns:
true if the component is in the word-wrap mode, false if not.

setWordwrap

@Deprecated
public void setWordwrap(boolean wordwrap)

Deprecated. Starting from 6.5 use TextArea for a multi-line text input.

Sets the editor's word-wrap mode on or off.

Parameters:
wordwrap - the boolean value specifying if the editor should be in word-wrap mode after the call or not.

setHeight

public void setHeight(float height,
                      int unit)

Sets the height of the TextField instance.

Setting height for TextField also has a side-effect that puts TextField into multiline mode (aka "textarea"). Multiline mode can also be achieved by calling setRows(int). The height value overrides the number of rows set by setRows(int).

If you want to set height of single line TextField, call setRows(int) with value 0 after setting the height. Setting rows to 0 resets the side-effect.

Starting from 6.5 you should use TextArea instead of TextField for multiline text input.

Specified by:
setHeight in interface Sizeable
Overrides:
setHeight in class AbstractComponent

Parameters:
height - the height of the object.
unit - the unit used for the width. Possible values include Sizeable.UNITS_PIXELS, Sizeable.UNITS_POINTS, Sizeable.UNITS_PICAS, Sizeable.UNITS_EM, Sizeable.UNITS_EX, Sizeable.UNITS_MM, Sizeable.UNITS_CM, Sizeable.UNITS_INCH, Sizeable.UNITS_PERCENTAGE.
See Also:
AbstractComponent.setHeight(float, int)

setHeight

public void setHeight(String height)

Sets the height of the TextField instance.

Setting height for TextField also has a side-effect that puts TextField into multiline mode (aka "textarea"). Multiline mode can also be achieved by calling setRows(int). The height value overrides the number of rows set by setRows(int).

If you want to set height of single line TextField, call setRows(int) with value 0 after setting the height. Setting rows to 0 resets the side-effect.

Specified by:
setHeight in interface Sizeable
Overrides:
setHeight in class AbstractComponent

Parameters:
height - in CSS style string representation
See Also:
AbstractComponent.setHeight(java.lang.String)