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.logical.shared.HasAttachHandlers, com.google.gwt.event.shared.HasHandlers, com.google.gwt.user.client.EventListener, com.google.gwt.user.client.ui.IsWidget
Direct Known Subclasses:
FileUploadField, TextArea, TriggerField

public class TextField<D>
extends Field<D>

Basic text field. Code snippet:

 TextField<String> text = new TextField<String>();
     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
protected  java.lang.String emptyStyle
           
protected static com.google.gwt.user.client.ui.impl.TextBoxImpl impl
           
protected  El input
           
protected  Validator validator
           
 
Fields inherited from class com.extjs.gxt.ui.client.widget.form.Field
autoValidate, emptyText, errorIcon, fieldStyle, focusStyle, focusValue, forceInvalidText, hasFocus, images, invalidStyle, messages, name, originalValue, preventMark, propertyEditor, readOnly, readOnlyFieldStyle, validationDelay, validationTask, value
 
Fields inherited from class com.extjs.gxt.ui.client.widget.BoxComponent
adjustSize, cacheSizes, ensureVisibilityOnSizing, height, lastSize, layer, shim, width
 
Fields inherited from class com.extjs.gxt.ui.client.widget.Component
afterRender, attachables, baseStyle, disabled, disabledStyle, disableTextSelection, dummy, focusable, hidden, mask, maskMessage, maskMessageStyleName, monitorWindowResize, rendered, resizeHandler, setElementRender, stateId, swallowEvents, toolTip, windowResizeDelay, windowResizeTask
 
Fields inherited from class com.google.gwt.user.client.ui.UIObject
DEBUG_ID_PREFIX
 
Constructor Summary
TextField()
          Creates a new text field.
 
Method Summary
protected  Size adjustInputSize()
           
protected  void applyEmptyText()
           
 boolean getAllowBlank()
          Returns the field's allow blank state.
 int getCursorPos()
          Returns the cursor position.
protected  El getFocusEl()
           
protected  El getInputEl()
          Provides support for wrapping the actual input element.
 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.
protected  El getStyleEl()
           
 Validator getValidator()
          Returns the field's validator instance.
 boolean isPassword()
          Returns true if the field is a password field.
protected  void onBlur(ComponentEvent be)
           
 void onComponentEvent(ComponentEvent ce)
          Any events a component receives will be forwarded to this method.
protected  void onFocus(ComponentEvent be)
           
protected  void onRender(com.google.gwt.user.client.Element target, int index)
          Subclasses must override and ensure setElement is called for lazy rendered components.
protected  void onResize(int width, int height)
          Called after the component is resized, this method is empty by default but can be implemented by any subclass that needs to perform custom logic after a resize occurs.
protected  void removeEmptyText()
           
 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 valid when its value length = 0 (default to true).
protected  void setAriaState(java.lang.String stateName, java.lang.String stateValue)
           
 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.
protected  boolean validateValue(java.lang.String value)
          Subclasses should provide the validation implementation by overriding this.
 
Methods inherited from class com.extjs.gxt.ui.client.widget.form.Field
addInputStyleName, addKeyListener, afterRender, alignErrorIcon, clear, clearInvalid, createComponentEvent, doDetachChildren, findLabelElement, fireChangeEvent, fireKey, focus, forceInvalid, getAutoValidate, getEmptyText, getErrorMessage, getFieldLabel, getImages, getLabelSeparator, getLabelStyle, getMessageTarget, getName, getOriginalValue, getPropertyEditor, getRawValue, getValidateOnBlur, getValidationDelay, getValue, initValue, isDirty, isFireChangeEventOnSetValue, isHideLabel, isInEditor, isReadOnly, isValid, isValid, markInvalid, onClick, onDetach, onDisable, onEnable, onHide, onKeyDown, onKeyPress, onKeyUp, onShow, removeInputStyleName, removeKeyListener, reset, setAutoValidate, setFieldLabel, setFireChangeEventOnSetValue, setHideLabel, setImages, setInEditor, setInputStyleAttribute, 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
adjustPosition, adjustSize, getBounds, getHeight, getHeight, getPosition, getPositionEl, getResizeEl, getShadow, getShadowOffset, getShadowPosition, getSize, getWidth, getWidth, hideShadow, hideShim, hideUnders, isAutoHeight, isAutoWidth, isDeferHeight, isShim, onPosition, onUnload, 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
addAttachable, addListener, addPlugin, addStyleName, addStyleOnOver, addWidgetListener, applyState, assertAfterRender, assertPreRender, beforeRender, blur, clearState, createObservable, createStyles, disable, disableContextMenu, disableEvents, disableTextSelection, doAttachChildren, el, enable, enableEvents, fireEvent, fireEvent, fireEvent, fly, frame, getAriaSupport, getBaseStyle, getBorders, getContextMenu, getData, getElement, getFocusSupport, getHideMode, getId, getItemId, getListeners, getModel, getObservable, getPlugins, getState, getStateId, getTabIndex, getTitle, getToolTip, getWindowResizeDelay, hasListeners, hasListeners, hide, hideToolTip, initState, isDisabledEvents, isDisableTextSelection, isEnabled, isMasked, isMonitorWindowResize, isRendered, isStateful, isVisible, isVisible, mask, mask, mask, notifyHide, notifyShow, onAttach, onBrowserEvent, onDetachHelper, onEnsureDebugId, onHideContextMenu, onLoad, onRightClick, onShowContextMenu, onWindowResize, previewEvent, recalculate, removeAllListeners, removeAttachagle, removeFromParent, removeListener, removeStyleName, removeStyleOnOver, removeSwallow, removeToolTip, removeWidgetListener, render, render, repaint, saveState, setAriaRole, setAriaSupport, setBorders, setContextMenu, setData, setEl, setElement, setElement, setEnabled, setFiresEvents, setHideMode, setId, setIntStyleAttribute, setItemId, setModel, setMonitorWindowResize, setParent, setStateful, setStateId, setStyleAttribute, setStyleName, setTitle, setToolTip, setToolTip, setVisible, setWindowResizeDelay, setZIndex, show, sinkEvents, swallowEvent, swallowEvent, toString, unframe, unmask
 
Methods inherited from class com.google.gwt.user.client.ui.Widget
addAttachHandler, addBitlessDomHandler, addDomHandler, addHandler, asWidget, asWidgetOrNull, createHandlerManager, delegateEvent, fireEvent, getHandlerCount, getLayoutData, getParent, isAttached, isOrWasAttached, setLayoutData
 
Methods inherited from class com.google.gwt.user.client.ui.UIObject
addStyleDependentName, ensureDebugId, ensureDebugId, ensureDebugId, getAbsoluteLeft, getAbsoluteTop, getOffsetHeight, getOffsetWidth, getStyleElement, getStyleName, getStyleName, getStylePrimaryName, getStylePrimaryName, isVisible, removeStyleDependentName, setElement, setStyleDependentName, setStyleName, setStyleName, setStyleName, setStylePrimaryName, setStylePrimaryName, setVisible, sinkBitlessEvent, unsinkEvents
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

impl

protected static com.google.gwt.user.client.ui.impl.TextBoxImpl impl

emptyStyle

protected java.lang.String emptyStyle

input

protected El input

validator

protected Validator validator
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

onComponentEvent

public void onComponentEvent(ComponentEvent ce)
Description copied from class: Component
Any events a component receives will be forwarded to this method. Subclasses should override as needed. The Component.onBrowserEvent(com.google.gwt.user.client.Event) method should not be overridden or modified.

Overrides:
onComponentEvent in class Field<D>
Parameters:
ce - the base event

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 valid 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

adjustInputSize

protected Size adjustInputSize()

applyEmptyText

protected void applyEmptyText()

getFocusEl

protected El getFocusEl()
Overrides:
getFocusEl in class Component

getInputEl

protected El getInputEl()
Description copied from class: Field
Provides support for wrapping the actual input element.

Overrides:
getInputEl in class Field<D>
Returns:
the input element

getStyleEl

protected El getStyleEl()
Overrides:
getStyleEl in class Field<D>

onBlur

protected void onBlur(ComponentEvent be)
Overrides:
onBlur in class Field<D>

onFocus

protected void onFocus(ComponentEvent be)
Overrides:
onFocus in class Field<D>

onRender

protected void onRender(com.google.gwt.user.client.Element target,
                        int index)
Description copied from class: Component
Subclasses must override and ensure setElement is called for lazy rendered components.

Overrides:
onRender in class Field<D>
Parameters:
target - the target element
index - the insert location

onResize

protected void onResize(int width,
                        int height)
Description copied from class: BoxComponent
Called after the component is resized, this method is empty by default but can be implemented by any subclass that needs to perform custom logic after a resize occurs.

Overrides:
onResize in class Field<D>
Parameters:
width - the width
height - the height

removeEmptyText

protected void removeEmptyText()

setAriaState

protected void setAriaState(java.lang.String stateName,
                            java.lang.String stateValue)
Overrides:
setAriaState in class Component

validateValue

protected boolean validateValue(java.lang.String value)
Description copied from class: Field
Subclasses should provide the validation implementation by overriding this.

Overrides:
validateValue in class Field<D>
Parameters:
value - the value to validate
Returns:
true for valid