com.gwtext.client.widgets.form
Class NumberField

java.lang.Object
  extended by com.google.gwt.user.client.ui.UIObject
      extended by com.google.gwt.user.client.ui.Widget
          extended by com.gwtext.client.widgets.Component
              extended by com.gwtext.client.widgets.BoxComponent
                  extended by com.gwtext.client.widgets.form.Field
                      extended by com.gwtext.client.widgets.form.TextField
                          extended by com.gwtext.client.widgets.form.NumberField
All Implemented Interfaces:
com.google.gwt.user.client.EventListener, Observable

public class NumberField
extends TextField

Numeric text field that provides automatic keystroke filtering and numeric validation.


Field Summary
 
Fields inherited from class com.gwtext.client.widgets.Component
config, id
 
Constructor Summary
NumberField()
          Creates a new NumberField.
NumberField(com.google.gwt.core.client.JavaScriptObject jsObj)
           
NumberField(java.lang.String fieldLabel)
           
NumberField(java.lang.String fieldLabel, java.lang.String name)
           
NumberField(java.lang.String fieldLabel, java.lang.String name, int width)
           
NumberField(java.lang.String fieldLabel, java.lang.String name, int width, float value)
           
 
Method Summary
protected  com.google.gwt.core.client.JavaScriptObject create(com.google.gwt.core.client.JavaScriptObject jsObj)
           
 java.lang.Number getValue()
          Returns the field value.
 java.lang.String getXType()
          Gets the xtype for this component as registered with ComponentMgr.
 void setAllowDecimals(boolean allowDecimals)
          False to disallow decimal values (defaults to true).
 void setAllowNegative(boolean allowNegative)
          False to prevent entering a negative sign (defaults to true).
 void setDecimalPrecision(int decimalPrecision)
          The maximum precision to display after the decimal separator (defaults to 2).
 void setDecimalSeparator(java.lang.String decimalSeparator)
          Character(s) to allow as the decimal separator (defaults to '.').
 void setMaxText(java.lang.String maxText)
          Error text to display if the maximum value validation fails (defaults to "The maximum value for this field is {maxValue}").
 void setMaxValue(int maxValue)
          The maximum allowed value (defaults to Number.MAX_VALUE).
 void setMinText(java.lang.String minText)
          Error text to display if the minimum value validation fails (defaults to "The minimum value for this field is {minValue}").
 void setMinValue(int minValue)
          The minimum allowed value (defaults to Number.NEGATIVE_INFINITY).
 void setNanText(java.lang.String nanText)
          Error text to display if the value is not a valid number.
 void setValue(float value)
          Sets the fields value.
 void setValue(java.lang.Number value)
          Sets the fields value.
 boolean validateValue(float value)
          Validates a value according to the field's validation rules and marks the field as invalid if the validation fails.
 boolean validateValue(java.lang.Number value)
          Validates a value according to the field's validation rules and marks the field as invalid if the validation fails.
 
Methods inherited from class com.gwtext.client.widgets.form.TextField
addKeyListener, addKeyListener, addKeyListener, addKeyPressListener, addKeyPressListener, addListener, autoSize, getConfigPrototype, getText, selectText, selectText, setAllowBlank, setBlankText, setDisableKeyFilter, setEmptyClass, setEmptyText, setGrow, setGrowMax, setGrowMin, setMaskRe, setMaxLength, setMaxLengthText, setMinLength, setMinLengthText, setPassword, setRegex, setRegexText, setSelectOnFocus, setValidator, setVtype, setVtypeText, validateValue
 
Methods inherited from class com.gwtext.client.widgets.form.Field
addListener, applyTo, applyTo, clearInvalid, getClearCls, getCls, getFieldLabel, getFocusClass, getInputType, getInvalidClass, getInvalidText, getLabelSeparator, getLabelStyle, getName, getRawValue, getTabindex, getValidationDelay, getValueAsString, hide, isAutoCreate, isDirty, isHideLabel, isReadOnly, isValid, isValid, isValidateOnBlur, markInvalid, reset, setAutoCreate, setAutoCreate, setClearCls, setCls, setDisabled, setFieldClass, setFieldLabel, setFieldMsgTarget, setFocusClass, setHideLabel, setInputType, setInvalidClass, setInvalidText, setLabel, setLabelSeparator, setLabelStyle, setMsgFx, setMsgTarget, setName, setRawValue, setReadOnly, setTabIndex, setValidateOnBlur, setValidationDelay, setValidationEvent, setValidationEvent, setValue, show, validate
 
Methods inherited from class com.gwtext.client.widgets.BoxComponent
addListener, doOnRender, doOnRender, getAutoHeight, getAutoWidth, getBox, getBox, getHeight, getPosition, getPosition, getSize, getWidth, setAutoHeight, setAutoWidth, setHeight, setHeight, setPagePosition, setPosition, setSize, setSize, setWidth, setWidth, syncSize, updateBox
 
Methods inherited from class com.gwtext.client.widgets.Component
addClass, addClassCreated, addEvent, addEvents, addListener, addListener, addListener, addPlugin, addStyleDependentName, addStyleName, afterRender, beforeDestroy, check, checkExtVer, cloneComponent, cloneComponent, cloneConfig, destroy, disable, enable, equals, error, findParentBy, findParentByType, fireEvent, focus, focus, focus, getApplyTo, getAttribute, getAttributeAsBoolean, getAttributeAsFloat, getAttributeAsInt, getAttributeAsJavaScriptObject, getAutoShow, getComponentJS, getConfig, getConfigAsString, getCtCls, getDisabledClass, getEl, getElement, getElement, getElement, getHideMode, getHideParent, getId, getItemId, getJsObj, getOffsetHeight, getOffsetWidth, getOrCreateJsObj, getOwnerContainer, getRenderTo, getStateEvents, getStateId, getTitle, getXTypes, hashCode, initComponent, isCreated, isDisabled, isHidden, isRendered, isVisible, isXType, isXType, onDestroy, purgeListeners, removeClass, removeStyleDependentName, removeStyleName, render, render, render, render, render, render, resumeEvents, setApplyTo, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAutoEl, setAutoEl, setAutoShow, setCtCls, setDisabledClass, setEl, setEl, setElement, setHideMode, setHideParent, setId, setRenderTo, setRenderToID, setStateEvents, setStateId, setStyle, setStyle, setStyleName, setStylePrimaryName, setTitle, setVisible, suspendEvents, toString
 
Methods inherited from class com.google.gwt.user.client.ui.Widget
doAttachChildren, doDetachChildren, getParent, isAttached, onAttach, onBrowserEvent, onDetach, onLoad, onUnload, removeFromParent
 
Methods inherited from class com.google.gwt.user.client.ui.UIObject
getAbsoluteLeft, getAbsoluteTop, getStyleElement, getStyleName, getStyleName, getStylePrimaryName, getStylePrimaryName, isVisible, setPixelSize, setStyleName, setStyleName, setStylePrimaryName, setVisible, sinkEvents, unsinkEvents
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

NumberField

public NumberField()
Creates a new NumberField.


NumberField

public NumberField(java.lang.String fieldLabel)

NumberField

public NumberField(java.lang.String fieldLabel,
                   java.lang.String name)

NumberField

public NumberField(java.lang.String fieldLabel,
                   java.lang.String name,
                   int width)

NumberField

public NumberField(java.lang.String fieldLabel,
                   java.lang.String name,
                   int width,
                   float value)

NumberField

public NumberField(com.google.gwt.core.client.JavaScriptObject jsObj)
Method Detail

create

protected com.google.gwt.core.client.JavaScriptObject create(com.google.gwt.core.client.JavaScriptObject jsObj)
Overrides:
create in class TextField

getValue

public java.lang.Number getValue()
Returns the field value.

Returns:
the field value

setValue

public void setValue(float value)
Sets the fields value.

Parameters:
value - the field value

setValue

public void setValue(java.lang.Number value)
Sets the fields value.

Parameters:
value - the field value

validateValue

public boolean validateValue(java.lang.Number value)
Validates a value according to the field's validation rules and marks the field as invalid if the validation fails.

Parameters:
value - the value to validate
Returns:
true if valid

validateValue

public boolean validateValue(float value)
Validates a value according to the field's validation rules and marks the field as invalid if the validation fails.

Parameters:
value - the value to validate
Returns:
true if valid

getXType

public java.lang.String getXType()
Description copied from class: Component
Gets the xtype for this component as registered with ComponentMgr. For a list of all available xtypes, see the Component javadocs.

 
 

TextField field = new TextField(); field.getXType() returns "textfield"

Overrides:
getXType in class TextField
Returns:
the xtype

setAllowDecimals

public void setAllowDecimals(boolean allowDecimals)
                      throws java.lang.IllegalStateException
False to disallow decimal values (defaults to true).

Parameters:
allowDecimals - false to disallow decimal values
Throws:
java.lang.IllegalStateException - this property cannot be changed after the Component has been rendered

setAllowNegative

public void setAllowNegative(boolean allowNegative)
                      throws java.lang.IllegalStateException
False to prevent entering a negative sign (defaults to true).

Parameters:
allowNegative - false to prevent entering a negative sign
Throws:
java.lang.IllegalStateException - this property cannot be changed after the Component has been rendered

setDecimalPrecision

public void setDecimalPrecision(int decimalPrecision)
                         throws java.lang.IllegalStateException
The maximum precision to display after the decimal separator (defaults to 2).

Parameters:
decimalPrecision - the decimal precision
Throws:
java.lang.IllegalStateException - this property cannot be changed after the Component has been rendered

setDecimalSeparator

public void setDecimalSeparator(java.lang.String decimalSeparator)
                         throws java.lang.IllegalStateException
Character(s) to allow as the decimal separator (defaults to '.').

Parameters:
decimalSeparator - decimal separator
Throws:
java.lang.IllegalStateException - this property cannot be changed after the Component has been rendered

setMaxText

public void setMaxText(java.lang.String maxText)
Error text to display if the maximum value validation fails (defaults to "The maximum value for this field is {maxValue}").

Parameters:
maxText - the max error text

setMaxValue

public void setMaxValue(int maxValue)
The maximum allowed value (defaults to Number.MAX_VALUE).

Parameters:
maxValue - the max value

setMinText

public void setMinText(java.lang.String minText)
Error text to display if the minimum value validation fails (defaults to "The minimum value for this field is {minValue}").

Parameters:
minText - the min error text

setMinValue

public void setMinValue(int minValue)
The minimum allowed value (defaults to Number.NEGATIVE_INFINITY).

Parameters:
minValue - the min value

setNanText

public void setNanText(java.lang.String nanText)
Error text to display if the value is not a valid number. For example, this can happen if a valid character like '.' or '-' is left in the field with no number (defaults to "throws IllegalArgumentException {value} is not a valid number").

Parameters:
nanText - the Nan text