com.extjs.gxt.ui.client.widget.form
Class TextField<D>

java.lang.Object
  extended by com.google.gwt.user.client.ui.UIObject
      extended by com.google.gwt.user.client.ui.Widget
          extended by com.extjs.gxt.ui.client.widget.Component
              extended by com.extjs.gxt.ui.client.widget.BoxComponent
                  extended by com.extjs.gxt.ui.client.widget.form.Field<D>
                      extended by com.extjs.gxt.ui.client.widget.form.TextField<D>
Type Parameters:
D - the data type
All Implemented Interfaces:
Observable, com.google.gwt.event.shared.HasHandlers, com.google.gwt.user.client.EventListener
Direct Known Subclasses:
FileUploadField, NumberField, TextArea, TriggerField

public class TextField<D>
extends Field<D>

Basic text field. Code snippet:

 TextField<String> text = new TextField&ltString>();
     text.setFieldLabel("Name");
     text.setEmptyText("Enter your full name");
     text.setAllowBlank(false);
     text.setMinLength(4);
 
Inherited Events:
Field Focus
Field Blur
Field Change
Field Invalid
Field Valid
Field KeyPress
Field SpecialKey
BoxComponent Move
BoxComponent Resize
Component Enable
Component Disable
Component BeforeHide
Component Hide
Component BeforeShow
Component Show
Component Attach
Component Detach
Component BeforeRender
Component Render
Component BrowserEvent
Component BeforeStateRestore
Component StateRestore
Component BeforeStateSave
Component SaveState

See Also:
NumberField

Nested Class Summary
 class TextField.TextFieldMessages
          TextField Messages.
 
Nested classes/interfaces inherited from class com.extjs.gxt.ui.client.widget.form.Field
Field.FieldImages, Field.FieldMessages
 
Nested classes/interfaces inherited from class com.google.gwt.user.client.ui.UIObject
com.google.gwt.user.client.ui.UIObject.DebugIdImpl, com.google.gwt.user.client.ui.UIObject.DebugIdImplEnabled
 
Field Summary
 
Fields inherited from class com.google.gwt.user.client.ui.UIObject
DEBUG_ID_PREFIX
 
Constructor Summary
TextField()
          Creates a new text field.
 
Method Summary
 boolean getAllowBlank()
          Returns the field's allow blank state.
 int getCursorPos()
          Returns the cursor position.
 int getMaxLength()
          Returns the field's max length.
 TextField.TextFieldMessages getMessages()
          Returns the field's messages.
 int getMinLength()
          Returns the minimum length.
 java.lang.String getRegex()
          Returns the field's regex value.
 java.lang.String getSelectedText()
          Returns the selected text.
 int getSelectionLength()
          Returns the length of the current selection.
 boolean getSelectOnFocus()
          Returns the select of focus state.
 Validator getValidator()
          Returns the field's validator instance.
 boolean isPassword()
          Returns true if the field is a password field.
 void select(int start, int length)
          Selects text in the field.
 void selectAll()
          Selects all the text.
 void setAllowBlank(boolean allowBlank)
          Sets whether a field is value when its value length = 0 (default to true).
 void setCursorPos(int pos)
          Sets the cursor position.
 void setEmptyText(java.lang.String emptyText)
          Sets the default text to display in an empty field.
 void setMaxLength(int maxLength)
          Sets the maximum input field length.
 void setMinLength(int minLength)
          Minimum input field length required (defaults to 0).
 void setPassword(boolean password)
          True to create the text field as a password input (defaults to false, pre-render).
 void setRegex(java.lang.String regex)
          Sets regular expression to be tested against the field value during validation.
 void setSelectionRange(int pos, int length)
          Selects the range.
 void setSelectOnFocus(boolean selectOnFocus)
          True to automatically select any existing field text when the field receives input focus (defaults to false).
 void setValidator(Validator validator)
          Sets the validator instance to be called during field validation.
 void setValue(D value)
          Sets a data value into the field and validates it.
 
Methods inherited from class com.extjs.gxt.ui.client.widget.form.Field
addInputStyleName, addKeyListener, clearInvalid, focus, forceInvalid, getAutoValidate, getEmptyText, getErrorMessage, getFieldLabel, getImages, getLabelSeparator, getLabelStyle, getMessageTarget, getName, getOriginalValue, getPropertyEditor, getRawValue, getValidateOnBlur, getValidationDelay, getValue, isDirty, isFireChangeEventOnSetValue, isHideLabel, isInEditor, isReadOnly, isValid, isValid, markInvalid, onComponentEvent, removeInputStyleName, removeKeyListener, reset, setAutoValidate, setFieldLabel, setFireChangeEventOnSetValue, setHideLabel, setImages, setInEditor, setLabelSeparator, setLabelStyle, setMessages, setMessageTarget, setName, setOriginalValue, setPropertyEditor, setRawValue, setReadOnly, setTabIndex, setValidateOnBlur, setValidationDelay, updateOriginalValue, validate, validate
 
Methods inherited from class com.extjs.gxt.ui.client.widget.BoxComponent
getBounds, getHeight, getHeight, getPosition, getShadow, getShadowOffset, getShadowPosition, getSize, getWidth, getWidth, isAutoHeight, isAutoWidth, isDeferHeight, isShim, setAutoHeight, setAutoWidth, setBounds, setBounds, setDeferHeight, setHeight, setHeight, setPagePosition, setPagePosition, setPixelSize, setPosition, setShadow, setShadowOffset, setShadowPosition, setShim, setSize, setSize, setWidth, setWidth, sync, syncSize
 
Methods inherited from class com.extjs.gxt.ui.client.widget.Component
addListener, addPlugin, addStyleName, addWidgetListener, clearState, disable, disableEvents, disableTextSelection, el, enable, enableEvents, fireEvent, fireEvent, fireEvent, fly, getBaseStyle, getBorders, getContextMenu, getData, getElement, getHideMode, getId, getItemId, getListeners, getModel, getState, getStateId, getToolTip, hasListeners, hasListeners, hide, hideToolTip, isDisabledEvents, isEnabled, isRendered, isStateful, isVisible, mask, mask, mask, onBrowserEvent, recalculate, removeAllListeners, removeFromParent, removeListener, removeStyleName, removeSwallow, removeToolTip, removeWidgetListener, render, render, repaint, saveState, setBorders, setContextMenu, setData, setElement, setEnabled, setHideMode, setId, setIntStyleAttribute, setItemId, setStateful, setStateId, setStyleAttribute, setStyleName, setTitle, setToolTip, setToolTip, setVisible, setZIndex, show, sinkEvents, swallowEvent, swallowEvent, toString, unmask
 
Methods inherited from class com.google.gwt.user.client.ui.Widget
fireEvent, getParent, isAttached
 
Methods inherited from class com.google.gwt.user.client.ui.UIObject
addStyleDependentName, ensureDebugId, ensureDebugId, getAbsoluteLeft, getAbsoluteTop, getOffsetHeight, getOffsetWidth, getStyleName, getStylePrimaryName, getTitle, isVisible, removeStyleDependentName, setStylePrimaryName, setVisible, unsinkEvents
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TextField

public TextField()
Creates a new text field.

Method Detail

getAllowBlank

public boolean getAllowBlank()
Returns the field's allow blank state.

Returns:
true if blank values are allowed

getCursorPos

public int getCursorPos()
Returns the cursor position.

Returns:
the cursor position

getMaxLength

public int getMaxLength()
Returns the field's max length.

Returns:
the max length

getMessages

public TextField.TextFieldMessages getMessages()
Description copied from class: Field
Returns the field's messages.

Overrides:
getMessages in class Field<D>
Returns:
the messages

getMinLength

public int getMinLength()
Returns the minimum length.

Returns:
the min length

getRegex

public java.lang.String getRegex()
Returns the field's regex value.

Returns:
the regex value

getSelectedText

public java.lang.String getSelectedText()
Returns the selected text.

Returns:
the selected text

getSelectionLength

public int getSelectionLength()
Returns the length of the current selection.

Returns:
the selection length

getSelectOnFocus

public boolean getSelectOnFocus()
Returns the select of focus state.

Returns:
true if select on focus is enabled

getValidator

public Validator getValidator()
Returns the field's validator instance.

Returns:
the validator

isPassword

public boolean isPassword()
Returns true if the field is a password field.

Returns:
that password state

select

public void select(int start,
                   int length)
Selects text in the field.

Parameters:
start - the index where the selection should start.
length - the number of characters to be selected

selectAll

public void selectAll()
Selects all the text.


setAllowBlank

public void setAllowBlank(boolean allowBlank)
Sets whether a field is value when its value length = 0 (default to true).

Parameters:
allowBlank - true to allow blanks, false otherwise

setCursorPos

public void setCursorPos(int pos)
Sets the cursor position.

Parameters:
pos - the position

setEmptyText

public void setEmptyText(java.lang.String emptyText)
Description copied from class: Field
Sets the default text to display in an empty field.

Overrides:
setEmptyText in class Field<D>
Parameters:
emptyText - the empty text

setMaxLength

public void setMaxLength(int maxLength)
Sets the maximum input field length.

Parameters:
maxLength - the max length

setMinLength

public void setMinLength(int minLength)
Minimum input field length required (defaults to 0).

Parameters:
minLength - the minimum length

setPassword

public void setPassword(boolean password)
True to create the text field as a password input (defaults to false, pre-render).

Parameters:
password - the password state

setRegex

public void setRegex(java.lang.String regex)
Sets regular expression to be tested against the field value during validation. If available, this regex will be evaluated only after the basic validators all return true. If the test fails, the field will be marked invalid using the regex error message.

Parameters:
regex - the regex expression

setSelectionRange

public void setSelectionRange(int pos,
                              int length)
Selects the range.

Parameters:
pos - the position
length - the range length

setSelectOnFocus

public void setSelectOnFocus(boolean selectOnFocus)
True to automatically select any existing field text when the field receives input focus (defaults to false).

Parameters:
selectOnFocus - true to focus

setValidator

public void setValidator(Validator validator)
Sets the validator instance to be called during field validation. It will be called only after the basic validators all return true, and will be passed the current field value and expected to return null if the value is valid or a string error message if invalid. Default value is null.

Parameters:
validator - the validator

setValue

public void setValue(D value)
Description copied from class: Field
Sets a data value into the field and validates it. If the field is rendered, To set the value directly without validation see Field.setRawValue(java.lang.String).

Overrides:
setValue in class Field<D>
Parameters:
value - the value to set