Interface Field<T>

Type Parameters:
T - the type of values in the field, which might not be the same type as that of the data source if converters are used
All Superinterfaces:
Buffered, BufferedValidatable, Property<T>, Property.Editor, Property.ReadOnlyStatusChangeListener, Property.ReadOnlyStatusChangeNotifier, Property.ValueChangeListener, Property.ValueChangeNotifier, Property.Viewer, Serializable, Validatable
All Known Subinterfaces:
FAbstractTextField, HasFInternalValue<T>, Select
All Known Implementing Classes:
AbstractField, CustomField, FAbstractField, FAbstractSelect, FCheckBox, FComboBox, FDateField, FListSelect, FPasswordField, FTextArea, FTextField, FTokenField, FTwinColSelect, Table

Field interface is implemented by all classes (field components) that have a value that the user can change through the user interface. Field components are built upon the framework defined in the Field interface and the AbstractField base clas. The Field interface inherits the Component superinterface and also the Property interface to have a value for the field.
Author:
Vaadin Ltd.
  • Method Details

    • getFAbstractField

      default FAbstractField<T> getFAbstractField()
    • setConverter

      default void setConverter(Converter<T,?> converter)
    • getConverter

      default Converter<T,?> getConverter()
    • getConvertedValue

      default Object getConvertedValue()
    • isRequired

      default boolean isRequired()
      Is this field required. Required fields must filled by the user.
      Returns:
      true if the field is required,otherwise false.
    • setRequired

      default void setRequired(boolean required)
      Sets the field required. Required fields must filled by the user.
      Parameters:
      required - Is the field required.
    • setRequiredError

      default void setRequiredError(String requiredMessage)
      Sets the error message to be displayed if a required field is empty.
      Parameters:
      requiredMessage - Error message.
    • getRequiredError

      default String getRequiredError()
      Gets the error message that is to be displayed if a required field is empty.
      Returns:
      Error message.
    • isEmpty

      boolean isEmpty()
      Is the field empty? In general, "empty" state is same as null. As an exception, TextField also treats empty string as "empty".
      Returns:
      true if the field is empty, false otherwise
    • isInvalidCommitted

      default boolean isInvalidCommitted()
      Description copied from interface: BufferedValidatable
      Tests if the invalid data is committed to datasource. The default is false.
      Specified by:
      isInvalidCommitted in interface BufferedValidatable
    • setInvalidCommitted

      default void setInvalidCommitted(boolean isCommitted)
      Description copied from interface: BufferedValidatable
      Sets if the invalid data should be committed to datasource. The default is false.
      Specified by:
      setInvalidCommitted in interface BufferedValidatable
    • commit

      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

      default 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.
    • setBuffered

      default void setBuffered(boolean buffered)
      Description copied from interface: Buffered
      Sets the buffered mode to the specified status.

      When in buffered mode, an internal buffer will be used to store changes until Buffered.commit() is called. Calling Buffered.discard() will revert the internal buffer to the value of the data source.

      When in non-buffered mode both read and write operations will be done directly on the data source. In this mode the Buffered.commit() and Buffered.discard() methods serve no purpose.

      Specified by:
      setBuffered in interface Buffered
      Parameters:
      buffered - true if buffered mode should be turned on, false otherwise
    • isBuffered

      default boolean isBuffered()
      Description copied from interface: Buffered
      Checks the buffered mode
      Specified by:
      isBuffered in interface Buffered
      Returns:
      true if buffered mode is on, false otherwise
    • isModified

      default 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.
    • addValidator

      default void addValidator(Validator validator)
      Description copied from interface: Validatable

      Adds a new validator for this object. The validator's Validator.validate(Object) method is activated every time the object's value needs to be verified, that is, when the Validatable.isValid() method is called. This usually happens when the object's value changes.

      Specified by:
      addValidator in interface Validatable
      Parameters:
      validator - the new validator
    • removeValidator

      default void removeValidator(Validator validator)
      Description copied from interface: Validatable

      Removes a previously registered validator from the object. The specified validator is removed from the object and its validate method is no longer called in Validatable.isValid().

      Specified by:
      removeValidator in interface Validatable
      Parameters:
      validator - the validator to remove
    • removeAllValidators

      default void removeAllValidators()
      Description copied from interface: Validatable
      Removes all validators from this object, as if removeValidator was called for each registered validator.
      Specified by:
      removeAllValidators in interface Validatable
    • getValidators

      default Collection<Validator> getValidators()
      Description copied from interface: Validatable

      Returns a collection of all validators currently registered for the object. The collection may be immutable. Calling removeValidator for this Validatable while iterating over the collection may be unsafe (e.g. may throw ConcurrentModificationException.)

      Specified by:
      getValidators in interface Validatable
      Returns:
      A collection of validators
    • isValid

      default boolean isValid()
      Description copied from interface: Validatable

      Tests the current value of the object against all registered validators. The registered validators are iterated and for each the Validator.validate(Object) method is called. If any validator throws the Validator.InvalidValueException this method returns false.

      Specified by:
      isValid in interface Validatable
      Returns:
      true if the registered validators concur that the value is valid, false otherwise
    • isInvalidAllowed

      default boolean isInvalidAllowed()
      Description copied from interface: Validatable

      Checks the validabtable object accept invalid values.The default value is true.

      Specified by:
      isInvalidAllowed in interface Validatable
    • setInvalidAllowed

      default void setInvalidAllowed(boolean invalidValueAllowed) throws UnsupportedOperationException
      Description copied from interface: Validatable

      Should the validabtable object accept invalid values. Supporting this configuration possibility is optional. By default invalid values are allowed.

      Specified by:
      setInvalidAllowed in interface Validatable
      Parameters:
      invalidValueAllowed -
      Throws:
      UnsupportedOperationException - if the setInvalidAllowed is not supported.
    • isPropertyReadOnly

      default boolean isPropertyReadOnly()
      Description copied from interface: Property
      Tests if the Property is in read-only mode. In read-only mode calls to the method setValue will throw ReadOnlyException and will not modify the value of the Property.
      Specified by:
      isPropertyReadOnly in interface Property<T>
      Returns:
      true if the Property is in read-only mode, false if it's not
    • setPropertyReadOnly

      default void setPropertyReadOnly(boolean newStatus)
      Description copied from interface: Property
      Sets the Property's read-only mode to the specified status. This functionality is optional, but all properties must implement the isReadOnly mode query correctly.
      Specified by:
      setPropertyReadOnly in interface Property<T>
      Parameters:
      newStatus - new read-only status of the Property
    • addValueChangeListener

      default void addValueChangeListener(Property.ValueChangeListener arg0)
      Description copied from interface: Property.ValueChangeNotifier
      Registers a new value change listener for this Property.
      Specified by:
      addValueChangeListener in interface Property.ValueChangeNotifier
      Parameters:
      arg0 - the new Listener to be registered
    • removeValueChangeListener

      default void removeValueChangeListener(Property.ValueChangeListener arg0)
      Description copied from interface: Property.ValueChangeNotifier
      Removes a previously registered value change listener.
      Specified by:
      removeValueChangeListener in interface Property.ValueChangeNotifier
      Parameters:
      arg0 - listener to be removed
    • valueChange

      default void valueChange(Property.ValueChangeEvent arg0)
      Description copied from interface: Property.ValueChangeListener
      Notifies this listener that the Property's value has changed.
      Specified by:
      valueChange in interface Property.ValueChangeListener
      Parameters:
      arg0 - value change event object
    • setPropertyDataSource

      default void setPropertyDataSource(Property newDataSource)
      Description copied from interface: Property.Viewer
      Sets the Property that serves as the data source of the viewer.
      Specified by:
      setPropertyDataSource in interface Property.Viewer
      Parameters:
      newDataSource - the new data source Property
    • getPropertyDataSource

      default Property getPropertyDataSource()
      Description copied from interface: Property.Viewer
      Gets the Property serving as the data source of the viewer.
      Specified by:
      getPropertyDataSource in interface Property.Viewer
      Returns:
      the Property serving as the viewers data source
    • getType

      default Class<? extends T> 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<T>
      Returns:
      type of the Property
    • addReadOnlyStatusChangeListener

      default void addReadOnlyStatusChangeListener(Property.ReadOnlyStatusChangeListener arg0)
      Description copied from interface: Property.ReadOnlyStatusChangeNotifier
      Registers a new read-only status change listener for this Property.
      Specified by:
      addReadOnlyStatusChangeListener in interface Property.ReadOnlyStatusChangeNotifier
      Parameters:
      arg0 - the new Listener to be registered
    • removeReadOnlyStatusChangeListener

      default void removeReadOnlyStatusChangeListener(Property.ReadOnlyStatusChangeListener arg0)
      Description copied from interface: Property.ReadOnlyStatusChangeNotifier
      Removes a previously registered read-only status change listener.
      Specified by:
      removeReadOnlyStatusChangeListener in interface Property.ReadOnlyStatusChangeNotifier
      Parameters:
      arg0 - listener to be removed
    • readOnlyStatusChange

      default void readOnlyStatusChange(Property.ReadOnlyStatusChangeEvent arg0)
      Description copied from interface: Property.ReadOnlyStatusChangeListener
      Notifies this listener that a Property's read-only status has changed.
      Specified by:
      readOnlyStatusChange in interface Property.ReadOnlyStatusChangeListener
      Parameters:
      arg0 - Read-only status change event object