com.vaadin.ui.


Class AbstractField

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

All Implemented Interfaces:

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

Direct Known Subclasses:

AbstractSelect, AbstractTextField, Button, DateField, Form, ProgressIndicator, RichTextArea, Slider

public abstract class AbstractField
extends AbstractComponent
implements Field, Property.ReadOnlyStatusChangeListener, Property.ReadOnlyStatusChangeNotifier, Action.ShortcutNotifier

Abstract field component for implementing buffered property editors. The field may hold an internal value, or it may be connected to any data source that implements the Propertyinterface. AbstractField implements that interface itself, too, so accessing the Property value represented by it is straightforward.

AbstractField also provides the Buffered interface for buffering the data source value. By default the Field is in write through-mode and setWriteThrough(boolean)should be called to enable buffering.

The class also supports validators to make sure the value contained in the field is valid.

Since:

3.0

Version:

6.8.18

Author:

Vaadin Ltd.

See Also:

Serialized Form

Nested Class Summary
static class AbstractField.FocusShortcut
          A ready-made ShortcutListener that focuses the given Focusable (usually a Field) when the keyboard shortcut is invoked.
 class AbstractField.ReadOnlyStatusChangeEvent
          An Event object specifying the Property whose read-only status has changed.
 
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
AbstractField()
           
 
Method Summary
 void addListener(Property.ReadOnlyStatusChangeListener listener)
          Registers a new read-only status change listener for this Property.
 void addListener(Property.ValueChangeListener listener)
          Registers a new value change listener for this Property.
 void addShortcutListener(ShortcutListener shortcut)
           
 void addValidator(Validator validator)
          Adds a new validator for the field's value.
 void attach()
          Notifies the component that it is connected to an application.
 void changeVariables(Object source, Map<String,Object> variables)
          Called when one or more variables handled by the implementing class are changed.
 void commit()
          Updates all changes since the previous commit to the data source.
static AbstractField constructField(Class<?> propertyType)
          Deprecated. use e.g. DefaultFieldFactory.createFieldByPropertyType(Class) instead
 void detach()
          Notifies the component that it is detached from the application.
 void discard()
          Discards all changes since last commit.
protected  void fireReadOnlyStatusChange()
          Emits the read-only status change event.
protected  void fireValueChange(boolean repaintIsNotNeeded)
          Emits the value change event.
 void focus()
          Sets the focus for this component if the component is Focusable.
protected  ActionManager getActionManager()
          Gets the ActionManager used to manage the ShortcutListeners added to this Field.
 ErrorMessage getErrorMessage()
          Error messages shown by the fields are composites of the error message thrown by the superclasses (that is the component error message), validation errors and buffered source errors.
 Property getPropertyDataSource()
          Gets the current data source of the field, if any.
 String getRequiredError()
          Gets the error message that is to be displayed if a required field is empty.
 int getTabIndex()
          Gets the tabulator index of the Focusable component.
abstract  Class<?> getType()
          Returns the type of the Property.
 Collection<Validator> getValidators()
          Gets the validators of the field.
 Object getValue()
          Gets the current value of the field.
protected  boolean isEmpty()
          Is the field empty? In general, "empty" state is same as null.
 boolean isInvalidAllowed()
          Fields allow invalid values by default.
 boolean isInvalidCommitted()
          Tests if the invalid data is committed to datasource.
 boolean isModified()
          Tests if the value stored in the object has been modified since it was last updated from the data source.
 boolean isReadOnly()
          The abstract field is read only also if the data source is in read only mode.
 boolean isReadThrough()
          Tests if the object is in read-through mode.
 boolean isRequired()
          Is this field required.
 boolean isValid()
          Tests the current value against registered validators if the field is not empty.
 boolean isValidationVisible()
          Is automatic, visible validation enabled? If automatic validation is enabled, any validators connected to this component are evaluated while painting the component and potential error messages are sent to client.
 boolean isWriteThrough()
          Tests if the object is in write-through mode.
 void paintContent(PaintTarget target)
          Paints any needed component-specific things to the given UIDL stream.
 void readOnlyStatusChange(Property.ReadOnlyStatusChangeEvent event)
          React to read only status changes of the property by requesting a repaint.
 void removeAllValidators()
          Removes all validators from the field.
 void removeListener(Property.ReadOnlyStatusChangeListener listener)
          Removes a previously registered read-only status change listener.
 void removeListener(Property.ValueChangeListener listener)
          Removes a previously registered value change listener.
 void removeShortcutListener(ShortcutListener shortcut)
           
 void removeValidator(Validator validator)
          Removes the validator from the field.
 void setCurrentBufferedSourceException(Buffered.SourceException currentBufferedSourceException)
          Sets the current buffered source exception.
protected  void setInternalValue(Object newValue)
          Sets the internal field value.
 void setInvalidAllowed(boolean invalidAllowed)
          Fields allow invalid values by default.
 void setInvalidCommitted(boolean isCommitted)
          Sets if the invalid data should be committed to datasource.
 void setPropertyDataSource(Property newDataSource)
           Sets the specified Property as the data source for the field.
 void setReadOnly(boolean readOnly)
          Changes the readonly state and throw read-only status change events.
 void setReadThrough(boolean readThrough)
          Sets the object's read-through mode to the specified status.
 void setRequired(boolean required)
          Sets the field required.
 void setRequiredError(String requiredMessage)
          Set the error that is show if this field is required, but empty.
 void setTabIndex(int tabIndex)
          Sets the tabulator index of the Focusable component.
 void setValidationVisible(boolean validateAutomatically)
          Enable or disable automatic, visible validation.
 void setValue(Object newValue)
          Sets the value of the field.
protected  void setValue(Object newValue, boolean repaintIsNotNeeded)
          Sets the value of the field.
 void setWriteThrough(boolean writeThrough)
          Sets the object's write-through mode to the specified status.
protected  boolean shouldHideErrors()
          Returns true if the error indicator be hidden when painting the component even when there are errors.
 String toString()
          Returns the value of the Property in human readable textual format.
 void validate()
          Checks the validity of the Validatable by validating the field with all attached validators except when the field is empty.
 void valueChange(Property.ValueChangeEvent event)
          This method listens to data source value changes and passes the changes forwards.
 
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, setHeight, 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

AbstractField

public AbstractField()
Method Detail

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 AbstractComponent

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

shouldHideErrors

protected boolean shouldHideErrors()

Returns true if the error indicator be hidden when painting the component even when there are errors. This is a mostly internal method, but can be overridden in subclasses e.g. if the error indicator should also be shown for empty fields in some cases.

Returns:
true to hide the error indicator, false to use the normal logic to show it when there are errors

getType

public abstract Class<?> getType()

Description copied from interface: Property

Returns the type of the Property. The methods getValue and setValue must be compatible with this type: one must be able to safely cast the value returned from getValue to the given type and pass any variable assignable to this type as an argument to setValue.

Specified by:
getType in interface Property

Returns:
type of the Property

isReadOnly

public boolean isReadOnly()

The abstract field is read only also if the data source is in read only mode.

Specified by:
isReadOnly in interface Property
Specified by:
isReadOnly in interface Component
Overrides:
isReadOnly in class AbstractComponent

Returns:
true if the component or any of its parents is in read-only mode, false if not.
See Also:
Component.setReadOnly(boolean)

setReadOnly

public void setReadOnly(boolean readOnly)

Changes the readonly state and throw read-only status change events.

Specified by:
setReadOnly in interface Property
Specified by:
setReadOnly in interface Component
Overrides:
setReadOnly in class AbstractComponent

Parameters:
readOnly - a boolean value specifying whether the component is put read-only mode or not
See Also:
Component.setReadOnly(boolean)

isInvalidCommitted

public boolean isInvalidCommitted()

Tests if the invalid data is committed to datasource.

Specified by:
isInvalidCommitted in interface BufferedValidatable

See Also:
BufferedValidatable.isInvalidCommitted()

setInvalidCommitted

public void setInvalidCommitted(boolean isCommitted)

Sets if the invalid data should be committed to datasource.

Specified by:
setInvalidCommitted in interface BufferedValidatable

See Also:
BufferedValidatable.setInvalidCommitted(boolean)

commit

public void commit()
            throws Buffered.SourceException,
                   Validator.InvalidValueException

Description copied from interface: Buffered

Updates all changes since the previous commit to the data source. The value stored in the object will always be updated into the data source when commit is called.

Specified by:
commit in interface Buffered

Throws:
Buffered.SourceException - if the operation fails because of an exception is thrown by the data source. The cause is included in the exception.
Validator.InvalidValueException - if the operation fails because validation is enabled and the values do not validate

discard

public void discard()
             throws Buffered.SourceException

Description copied from interface: Buffered

Discards all changes since last commit. The object updates its value from the data source.

Specified by:
discard in interface Buffered

Throws:
Buffered.SourceException - if the operation fails because of an exception is thrown by the data source. The cause is included in the exception.

isModified

public boolean isModified()

Description copied from interface: Buffered

Tests if the value stored in the object has been modified since it was last updated from the data source.

Specified by:
isModified in interface Buffered

Returns:
true if the value in the object has been modified since the last data source update, false if not.

isWriteThrough

public boolean isWriteThrough()

Description copied from interface: Buffered

Tests if the object is in write-through mode. If the object is in write-through mode, all modifications to it will result in commit being called after the modification.

Specified by:
isWriteThrough in interface Buffered

Returns:
true if the object is in write-through mode, false if it's not.

setWriteThrough

public void setWriteThrough(boolean writeThrough)
                     throws Buffered.SourceException,
                            Validator.InvalidValueException

Description copied from interface: Buffered

Sets the object's write-through mode to the specified status. When switching the write-through mode on, the commit operation will be performed.

Specified by:
setWriteThrough in interface Buffered

Parameters:
writeThrough - Boolean value to indicate if the object should be in write-through mode after the call.
Throws:
Buffered.SourceException - If the operation fails because of an exception is thrown by the data source.
Validator.InvalidValueException - If the implicit commit operation fails because of a validation error.

isReadThrough

public boolean isReadThrough()

Description copied from interface: Buffered

Tests if the object is in read-through mode. If the object is in read-through mode, retrieving its value will result in the value being first updated from the data source to the object.

The only exception to this rule is that when the object is not in write-through mode and it's buffer contains a modified value, the value retrieved from the object will be the locally modified value in the buffer which may differ from the value in the data source.

Specified by:
isReadThrough in interface Buffered

Returns:
true if the object is in read-through mode, false if it's not.

setReadThrough

public void setReadThrough(boolean readThrough)
                    throws Buffered.SourceException

Description copied from interface: Buffered

Sets the object's read-through mode to the specified status. When switching read-through mode on, the object's value is updated from the data source.

Specified by:
setReadThrough in interface Buffered

Parameters:
readThrough - Boolean value to indicate if the object should be in read-through mode after the call.
Throws:
Buffered.SourceException - If the operation fails because of an exception is thrown by the data source. The cause is included in the exception.

toString

public String toString()

Returns the value of the Property in human readable textual format.

Specified by:
toString in interface Property
Overrides:
toString in class Object

Returns:
String representation of the value stored in the Property
See Also:
Object.toString()

getValue

public Object getValue()

Gets the current value of the field.

This is the visible, modified and possible invalid value the user have entered to the field. In the read-through mode, the abstract buffer is also updated and validation is performed.

Note that the object returned is compatible with getType(). For example, if the type is String, this returns Strings even when the underlying datasource is of some other type. In order to access the datasources native type, use getPropertyDatasource().getValue() instead.

Note that when you extend AbstractField, you must reimplement this method if datasource.getValue() is not assignable to class returned by getType() AND getType() is not String. In case of Strings, getValue() calls datasource.toString() instead of datasource.getValue().

Specified by:
getValue in interface Property

Returns:
the current value of the field.

setValue

public void setValue(Object newValue)
              throws Property.ReadOnlyException,
                     Property.ConversionException

Sets the value of the field.

Specified by:
setValue in interface Property

Parameters:
newValue - the New value of the field.
Throws:
Property.ReadOnlyException
Property.ConversionException

setValue

protected void setValue(Object newValue,
                        boolean repaintIsNotNeeded)
                 throws Property.ReadOnlyException,
                        Property.ConversionException

Sets the value of the field.

Parameters:
newValue - the New value of the field.
repaintIsNotNeeded - True iff caller is sure that repaint is not needed.
Throws:
Property.ReadOnlyException
Property.ConversionException

getPropertyDataSource

public Property getPropertyDataSource()

Gets the current data source of the field, if any.

Specified by:
getPropertyDataSource in interface Property.Viewer

Returns:
the current data source as a Property, or null if none defined.

setPropertyDataSource

public void setPropertyDataSource(Property newDataSource)

Sets the specified Property as the data source for the field. All uncommitted changes are replaced with a value from the new data source.

If the datasource has any validators, the same validators are added to the field. Because the default behavior of the field is to allow invalid values, but not to allow committing them, this only adds visual error messages to fields and do not allow committing them as long as the value is invalid. After the value is valid, the error message is not shown and the commit can be done normally.

If the data source implements Property.ValueChangeNotifier and/or Property.ReadOnlyStatusChangeNotifier, the field registers itself as a listener and updates itself according to the events it receives. To avoid memory leaks caused by references to a field no longer in use, the listener registrations are removed on detach and re-added on attach.

Note: before 6.5 we actually called discard() method in the beginning of the method. This was removed to simplify implementation, avoid excess calls to backing property and to avoid odd value change events that were previously fired (developer expects 0-1 value change events if this method is called). Some complex field implementations might now need to override this method to do housekeeping similar to discard().

Specified by:
setPropertyDataSource in interface Property.Viewer

Parameters:
newDataSource - the new data source Property.

addValidator

public void addValidator(Validator validator)

Adds a new validator for the field's value. All validators added to a field are checked each time the its value changes.

Specified by:
addValidator in interface Validatable

Parameters:
validator - the new validator to be added.

getValidators

public Collection<Validator> getValidators()

Gets the validators of the field.

Specified by:
getValidators in interface Validatable

Returns:
the Unmodifiable collection that holds all validators for the field.

removeValidator

public void removeValidator(Validator validator)

Removes the validator from the field.

Specified by:
removeValidator in interface Validatable

Parameters:
validator - the validator to remove.

removeAllValidators

public void removeAllValidators()

Removes all validators from the field.

isValid

public boolean isValid()

Tests the current value against registered validators if the field is not empty. If the field is empty it is considered valid if it is not required and invalid otherwise. Validators are never checked for empty fields.

Specified by:
isValid in interface Validatable

Returns:
true if all registered validators claim that the current value is valid or if the field is empty and not required, false otherwise.

validate

public void validate()
              throws Validator.InvalidValueException

Checks the validity of the Validatable by validating the field with all attached validators except when the field is empty. An empty field is invalid if it is required and valid otherwise. The "required" validation is a built-in validation feature. If the field is required, but empty, validation will throw an EmptyValueException with the error message set with setRequiredError().

Specified by:
validate in interface Validatable

Throws:
Validator.InvalidValueException - if the value is not valid
See Also:
Validatable.validate()

isInvalidAllowed

public boolean isInvalidAllowed()

Fields allow invalid values by default. In most cases this is wanted, because the field otherwise visually forget the user input immediately.

Specified by:
isInvalidAllowed in interface Validatable

Returns:
true iff the invalid values are allowed.
See Also:
Validatable.isInvalidAllowed()

setInvalidAllowed

public void setInvalidAllowed(boolean invalidAllowed)
                       throws UnsupportedOperationException

Fields allow invalid values by default. In most cases this is wanted, because the field otherwise visually forget the user input immediately.

In common setting where the user wants to assure the correctness of the datasource, but allow temporarily invalid contents in the field, the user should add the validators to datasource, that should not allow invalid values. The validators are automatically copied to the field when the datasource is set.

Specified by:
setInvalidAllowed in interface Validatable

Throws:
UnsupportedOperationException - if the setInvalidAllowed is not supported.
See Also:
Validatable.setInvalidAllowed(boolean)

getErrorMessage

public ErrorMessage getErrorMessage()

Error messages shown by the fields are composites of the error message thrown by the superclasses (that is the component error message), validation errors and buffered source errors.

Overrides:
getErrorMessage in class AbstractComponent

Returns:
ErrorMessage containing the description of the error state of the component or null, if the component contains no errors. Extending classes should override this method if they support other error message types such as validation errors or buffering errors. The returned error message contains information about all the errors.
See Also:
AbstractComponent.getErrorMessage()

addListener

public void addListener(Property.ValueChangeListener listener)

Description copied from interface: Property.ValueChangeNotifier

Registers a new value change listener for this Property.

Specified by:
addListener in interface Property.ValueChangeNotifier

Parameters:
listener - the new Listener to be registered

removeListener

public void removeListener(Property.ValueChangeListener listener)

Description copied from interface: Property.ValueChangeNotifier

Removes a previously registered value change listener.

Specified by:
removeListener in interface Property.ValueChangeNotifier

Parameters:
listener - listener to be removed

fireValueChange

protected void fireValueChange(boolean repaintIsNotNeeded)

Emits the value change event. The value contained in the field is validated before the event is created.

readOnlyStatusChange

public void readOnlyStatusChange(Property.ReadOnlyStatusChangeEvent event)

React to read only status changes of the property by requesting a repaint.

Specified by:
readOnlyStatusChange in interface Property.ReadOnlyStatusChangeListener

Parameters:
event - Read-only status change event object
See Also:
Property.ReadOnlyStatusChangeListener

addListener

public void addListener(Property.ReadOnlyStatusChangeListener listener)

Description copied from interface: Property.ReadOnlyStatusChangeNotifier

Registers a new read-only status change listener for this Property.

Specified by:
addListener in interface Property.ReadOnlyStatusChangeNotifier

Parameters:
listener - the new Listener to be registered

removeListener

public void removeListener(Property.ReadOnlyStatusChangeListener listener)

Description copied from interface: Property.ReadOnlyStatusChangeNotifier

Removes a previously registered read-only status change listener.

Specified by:
removeListener in interface Property.ReadOnlyStatusChangeNotifier

Parameters:
listener - listener to be removed

fireReadOnlyStatusChange

protected void fireReadOnlyStatusChange()

Emits the read-only status change event. The value contained in the field is validated before the event is created.

valueChange

public void valueChange(Property.ValueChangeEvent event)

This method listens to data source value changes and passes the changes forwards. Changes are not forwarded to the listeners of the field during internal operations of the field to avoid duplicate notifications.

Specified by:
valueChange in interface Property.ValueChangeListener

Parameters:
event - the value change event telling the data source contents have changed.

changeVariables

public void changeVariables(Object source,
                            Map<String,Object> variables)

Description copied from interface: VariableOwner

Called when one or more variables handled by the implementing class are changed.

Specified by:
changeVariables in interface VariableOwner
Overrides:
changeVariables in class AbstractComponent

Parameters:
source - the Source of the variable change. This is the origin of the event. For example in Web Adapter this is the request.
variables - the Mapping from variable names to new variable values.

focus

public void focus()

Sets the focus for this component if the component is Focusable.

Specified by:
focus in interface Component.Focusable
Overrides:
focus in class AbstractComponent

See Also:
FieldEvents, FieldEvents.FocusEvent, FieldEvents.FocusListener, FieldEvents.BlurEvent, FieldEvents.BlurListener

constructField

@Deprecated
public static AbstractField constructField(Class<?> propertyType)

Deprecated. use e.g. DefaultFieldFactory.createFieldByPropertyType(Class) instead

Creates abstract field by the type of the property.

This returns most suitable field type for editing property of given type.

Parameters:
propertyType - the Type of the property, that needs to be edited.

getTabIndex

public int getTabIndex()

Description copied from interface: Component.Focusable

Gets the tabulator index of the Focusable component.

Specified by:
getTabIndex in interface Component.Focusable

Returns:
tab index set for the Focusable component
See Also:
Component.Focusable.setTabIndex(int)

setTabIndex

public void setTabIndex(int tabIndex)

Description copied from interface: Component.Focusable

Sets the tabulator index of the Focusable component. The tab index property is used to specify the order in which the fields are focused when the user presses the Tab key. Components with a defined tab index are focused sequentially first, and then the components with no tab index.

 Form loginBox = new Form();
 loginBox.setCaption("Login");
 layout.addComponent(loginBox);
 
 // Create the first field which will be focused
 TextField username = new TextField("User name");
 loginBox.addField("username", username);
 
 // Set focus to the user name
 username.focus();
 
 TextField password = new TextField("Password");
 loginBox.addField("password", password);
 
 Button login = new Button("Login");
 loginBox.getFooter().addComponent(login);
 
 // An additional component which natural focus order would
 // be after the button.
 CheckBox remember = new CheckBox("Remember me");
 loginBox.getFooter().addComponent(remember);
 
 username.setTabIndex(1);
 password.setTabIndex(2);
 remember.setTabIndex(3); // Different than natural place
 login.setTabIndex(4);
 

After all focusable user interface components are done, the browser can begin again from the component with the smallest tab index, or it can take the focus out of the page, for example, to the location bar.

If the tab index is not set (is set to zero), the default tab order is used. The order is somewhat browser-dependent, but generally follows the HTML structure of the page.

A negative value means that the component is completely removed from the tabulation order and can not be reached by pressing the Tab key at all.

Specified by:
setTabIndex in interface Component.Focusable

Parameters:
tabIndex - the tab order of this component. Indexes usually start from 1. Zero means that default tab order should be used. A negative value means that the field should not be included in the tabbing sequence.
See Also:
Component.Focusable.getTabIndex()

setInternalValue

protected void setInternalValue(Object newValue)

Sets the internal field value. This is purely used by AbstractField to change the internal Field value. It does not trigger valuechange events. It can be overridden by the inheriting classes to update all dependent variables.

Parameters:
newValue - the new value to be set.

attach

public void attach()

Notifies the component that it is connected to an application.

Specified by:
attach in interface Component
Overrides:
attach in class AbstractComponent

See Also:
Component.attach()

detach

public void detach()

Description copied from interface: Component

Notifies the component that it is detached from the application.

The Component.getApplication() and Component.getWindow() methods might return null after this method is called.

The caller of this method is Component.setParent(Component) if the parent is in the application. When the parent is detached from the application it is its response to call Component.detach() for all the children and to detach itself from the terminal.

Specified by:
detach in interface Component
Overrides:
detach in class AbstractComponent

isRequired

public boolean isRequired()

Is this field required. Required fields must filled by the user. If the field is required, it is visually indicated in the user interface. Furthermore, setting field to be required implicitly adds "non-empty" validator and thus isValid() == false or any isEmpty() fields. In those cases validation errors are not painted as it is obvious that the user must fill in the required fields. On the other hand, for the non-required fields isValid() == true if the field isEmpty() regardless of any attached validators.

Specified by:
isRequired in interface Field

Returns:
true if the field is required .otherwise false.

setRequired

public void setRequired(boolean required)

Sets the field required. Required fields must filled by the user. If the field is required, it is visually indicated in the user interface. Furthermore, setting field to be required implicitly adds "non-empty" validator and thus isValid() == false or any isEmpty() fields. In those cases validation errors are not painted as it is obvious that the user must fill in the required fields. On the other hand, for the non-required fields isValid() == true if the field isEmpty() regardless of any attached validators.

Specified by:
setRequired in interface Field

Parameters:
required - Is the field required.

setRequiredError

public void setRequiredError(String requiredMessage)

Set the error that is show if this field is required, but empty. When setting requiredMessage to be "" or null, no error pop-up or exclamation mark is shown for a empty required field. This faults to "". Even in those cases isValid() returns false for empty required fields.

Specified by:
setRequiredError in interface Field

Parameters:
requiredMessage - Message to be shown when this field is required, but empty.

getRequiredError

public String getRequiredError()

Description copied from interface: Field

Gets the error message that is to be displayed if a required field is empty.

Specified by:
getRequiredError in interface Field

Returns:
Error message.

isEmpty

protected boolean isEmpty()

Is the field empty? In general, "empty" state is same as null. As an exception, TextField also treats empty string as "empty".

isValidationVisible

public boolean isValidationVisible()

Is automatic, visible validation enabled? If automatic validation is enabled, any validators connected to this component are evaluated while painting the component and potential error messages are sent to client. If the automatic validation is turned off, isValid() and validate() methods still work, but one must show the validation in their own code.

Returns:
True, if automatic validation is enabled.

setValidationVisible

public void setValidationVisible(boolean validateAutomatically)

Enable or disable automatic, visible validation. If automatic validation is enabled, any validators connected to this component are evaluated while painting the component and potential error messages are sent to client. If the automatic validation is turned off, isValid() and validate() methods still work, but one must show the validation in their own code.

Parameters:
validateAutomatically - True, if automatic validation is enabled.

setCurrentBufferedSourceException

public void setCurrentBufferedSourceException(Buffered.SourceException currentBufferedSourceException)

Sets the current buffered source exception.

Parameters:
currentBufferedSourceException -

getActionManager

protected ActionManager getActionManager()

Gets the ActionManager used to manage the ShortcutListeners added to this Field.

Returns:
the ActionManager in use

addShortcutListener

public void addShortcutListener(ShortcutListener shortcut)

Specified by:
addShortcutListener in interface Action.ShortcutNotifier

removeShortcutListener

public void removeShortcutListener(ShortcutListener shortcut)

Specified by:
removeShortcutListener in interface Action.ShortcutNotifier