T
- the field's data typepublic abstract class Field<T> extends CellComponent<T> implements IsField<T>, HasValue<T>, HasValueChangeHandlers<T>, HasName, InvalidEvent.HasInvalidHandlers, ValidEvent.HasValidHandlers, LeafValueEditor<T>, HasEditorErrors<T>, HasEditorDelegate<T>, ValueAwareEditor<T>, HasErrorHandler
The Field instance implements several Editor interfaces to participate in the full editing lifecycle.
LeafValueEditor
indicates that this class will have no sub-editors, and can have new values set on it,
and retrieved when the driver is flushed.HasEditorDelegate
provides access to the delegate to report validation and parse errors to the driverHasEditorErrors
indicates that the field should be informed when the driver is given an error that
applies to the data the field contains, so that it can present it to the user.ValueAwareEditor
is used to learn when the editor driver is flushing values so that current errors can be
reported to the error delegate, and collected at the driver
All errors are displayed through a ErrorHandler
instance, whether they arrive from the Cell's parsing, the
Field's validation, or from validation errors given to an editor driver. Events are also dispatched when the validity
of the field changes.
Modifier and Type | Class and Description |
---|---|
static interface |
Field.FieldStyles |
UIObject.DebugIdImpl, UIObject.DebugIdImplEnabled
DEBUG_ID_PREFIX
Modifier and Type | Method and Description |
---|---|
HandlerRegistration |
addInvalidHandler(InvalidEvent.InvalidHandler handler)
Adds a
InvalidEvent.InvalidHandler handler for InvalidEvent
events. |
void |
addValidator(Validator<T> validator) |
HandlerRegistration |
addValidHandler(ValidEvent.ValidHandler handler)
Adds a
ValidEvent handler for ValidEvent
events. |
HandlerRegistration |
addValueChangeHandler(ValueChangeHandler<T> handler) |
void |
clear()
Clears the value from the field.
|
void |
clearInvalid()
Clear any invalid styles / messages for this field.
|
void |
finishEditing()
Used to indicate that this field must be completed with its editing process, as it may be able to be removed from
the dom, hidden, or its current results used.
|
void |
flush() |
void |
forceInvalid(String msg)
Forces the field to be invalid using the given error message.
|
FieldCell<T> |
getCell()
Get the
Cell wrapped by this widget. |
List<EditorError> |
getErrors()
Returns a list of the current errors.
|
ErrorHandler |
getErrorSupport()
Returns the field's error support instance.
|
String |
getName()
Gets the field's name.
|
T |
getOriginalValue()
Returns the original value.
|
boolean |
getValidateOnBlur()
Returns
true if the value is validate on blur. |
int |
getValidationDelay()
Returns the field's validation delay in milliseconds.
|
List<Validator<T>> |
getValidators()
Returns the field's validators.
|
boolean |
isAutoValidate()
Returns
true if the field value is validated on each key press. |
boolean |
isEditing()
Return
true if the field is being edited. |
boolean |
isValid()
Returns whether or not the field value is currently valid.
|
boolean |
isValid(boolean preventMark)
Returns whether or not the field value is currently valid.
|
void |
markInvalid(String msg)
Marks this field as invalid.
|
void |
onBrowserEvent(Event event) |
void |
onPropertyChange(String... paths) |
void |
removeValidator(Validator<T> validator)
Removes the validator.
|
void |
reset()
Resets the current field value to the originally loaded value and clears any validation messages.
|
void |
setAutoValidate(boolean autoValidate)
Sets whether the value is validated on each key press (defaults to
false ). |
void |
setDelegate(EditorDelegate<T> delegate) |
void |
setErrorSupport(ErrorHandler error)
Sets the field's error support instance.
|
void |
setName(String name) |
void |
setOriginalValue(T value)
Sets the value the field will be set to when
reset() is called. |
void |
setReadOnly(boolean readOnly)
Sets the field's read only state.
|
void |
setValidateOnBlur(boolean validateOnBlur)
Sets whether the field should validate when it loses focus (defaults to
true ). |
void |
setValidationDelay(int validationDelay)
Sets length of time in milliseconds after user input begins until validation is initiated (defaults to 250).
|
void |
setValue(T value,
boolean fireEvents,
boolean redraw)
Sets this object's value and optionally redraw the widget.
|
void |
showErrors(List<EditorError> errors) |
boolean |
validate()
Validates the field value.
|
boolean |
validate(boolean preventMark)
Validates the field value.
|
getElement, getKeyProvider, getValue, redraw, setValue, setValue
addBeforeHideHandler, addBeforeShowContextMenuHandler, addBeforeShowHandler, addBlurHandler, addDisableHandler, addEnableHandler, addFocusHandler, addHideHandler, addMoveHandler, addResizeHandler, addShowContextMenuHandler, addShowHandler, addStyleOnOver, clearSizeCache, disable, disableEvents, enable, enableEvents, fireEvent, focus, getData, getFocusSupport, getHideMode, getId, getItemId, getOffsetHeight, getOffsetWidth, getShadow, getShadowPosition, getStateId, getTabIndex, getToolTip, hide, hideToolTip, isAllowTextSelection, isAutoHeight, isAutoWidth, isDeferHeight, isEnabled, isRendered, isStateful, isVisible, isVisible, mask, mask, removeToolTip, setAllowTextSelection, setBorders, setBounds, setBounds, setContextMenu, setData, setDeferHeight, setEnabled, setHeight, setHeight, setHideMode, setId, setItemId, setPagePosition, setPixelSize, setPosition, setShadow, setShadowPosition, setSize, setStateful, setStateId, setTabIndex, setToolTip, setToolTip, setToolTipConfig, setVisible, setWidth, setWidth, show, sync, syncSize, unmask
addAttachHandler, addBitlessDomHandler, addDomHandler, addHandler, asWidget, asWidgetOrNull, getLayoutData, getParent, isAttached, removeFromParent, setLayoutData, sinkEvents, unsinkEvents
addStyleDependentName, addStyleName, ensureDebugId, ensureDebugId, getAbsoluteLeft, getAbsoluteTop, getOffsetHeight, getOffsetWidth, getStyleName, getStylePrimaryName, getTitle, isVisible, removeStyleDependentName, removeStyleName, setStyleDependentName, setStyleName, setStyleName, setStylePrimaryName, setTitle, setVisible, sinkBitlessEvent, toString
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
getValue, setValue
addBlurHandler
getValue, setValue, setValue
fireEvent
setValue
public HandlerRegistration addInvalidHandler(InvalidEvent.InvalidHandler handler)
InvalidEvent.HasInvalidHandlers
InvalidEvent.InvalidHandler
handler for InvalidEvent
events.addInvalidHandler
in interface InvalidEvent.HasInvalidHandlers
handler
- the handlerpublic HandlerRegistration addValidHandler(ValidEvent.ValidHandler handler)
ValidEvent.HasValidHandlers
ValidEvent
handler for ValidEvent
events.addValidHandler
in interface ValidEvent.HasValidHandlers
handler
- the handlerpublic HandlerRegistration addValueChangeHandler(ValueChangeHandler<T> handler)
addValueChangeHandler
in interface HasValueChangeHandlers<T>
addValueChangeHandler
in class CellComponent<T>
public void clear()
IsField
clear
in interface IsField<T>
to remove validation messages
,
to restore to original value and remove validation messages
public void clearInvalid()
clearInvalid
in interface IsField<T>
public void finishEditing()
IsField
finishEditing
in interface IsField<T>
public void flush()
flush
in interface ValueAwareEditor<T>
public void forceInvalid(String msg)
clearInvalid()
must
be called to clear the error. Also, no other validation logic will execute.msg
- the error textpublic FieldCell<T> getCell()
CellComponent
Cell
wrapped by this widget.getCell
in class CellComponent<T>
Cell
being wrappedpublic List<EditorError> getErrors()
IsField
public ErrorHandler getErrorSupport()
HasErrorHandler
getErrorSupport
in interface HasErrorHandler
public String getName()
public T getOriginalValue()
public boolean getValidateOnBlur()
true
if the value is validate on blur.true
if validations run on blurpublic int getValidationDelay()
public List<Validator<T>> getValidators()
public boolean isAutoValidate()
true
if the field value is validated on each key press.true
if auto validatingpublic boolean isEditing()
true
if the field is being edited.true
if editingpublic boolean isValid()
true
if validpublic boolean isValid(boolean preventMark)
IsField
public void markInvalid(String msg)
forceInvalid(String)
msg
- the validation messagepublic void onBrowserEvent(Event event)
onBrowserEvent
in interface EventListener
onBrowserEvent
in class CellComponent<T>
public void onPropertyChange(String... paths)
onPropertyChange
in interface ValueAwareEditor<T>
public void removeValidator(Validator<T> validator)
validator
- the validator to removepublic void reset()
IsField
public void setAutoValidate(boolean autoValidate)
false
).autoValidate
- true
to validate on each key presspublic void setDelegate(EditorDelegate<T> delegate)
setDelegate
in interface HasEditorDelegate<T>
public void setErrorSupport(ErrorHandler error)
HasErrorHandler
setErrorSupport
in interface HasErrorHandler
error
- the error supportpublic void setOriginalValue(T value)
reset()
is called.value
- the original valuepublic void setReadOnly(boolean readOnly)
readOnly
- the read only statepublic void setValidateOnBlur(boolean validateOnBlur)
true
).validateOnBlur
- true
to validate on blur, otherwise falsepublic void setValidationDelay(int validationDelay)
validationDelay
- the delay in millisecondspublic void setValue(T value, boolean fireEvents, boolean redraw)
CellComponent
ValueChangeEvent
when
fireEvents is true and the new value does not equal the existing value.
Redraws the widget when redraw is true and the new value does not equal the
existing value.setValue
in class CellComponent<T>
value
- the object's new valuefireEvents
- fire events if true and value is newredraw
- redraw the widget if true and value is newpublic void showErrors(List<EditorError> errors)
showErrors
in interface HasEditorErrors<T>
public boolean validate()
true
if valid, otherwise false
public boolean validate(boolean preventMark)
IsField
Copyright © 2015. All rights reserved.