Class AbstractField<T extends com.vaadin.ui.Component & com.vaadin.data.HasValue<P>,P,V>

Type Parameters:
T - type of underlying Vaadin component
P - type of presentation value
V - type of model value
All Implemented Interfaces:
AttachNotifier, Component, Component.BelongToFrame, Component.Editable, Component.HasCaption, Component.HasDescription, Component.HasIcon, Component.HasXmlDescriptor, Component.Wrapper, HasValueSource<V>, Field<V>, HasContextHelp, HasDebugId, HasHtmlCaption, HasHtmlDescription, HasHtmlSanitizer, HasValidator<V>, HasValue<V>, Requirable, Validatable
Direct Known Subclasses:
AbstractSelectList, AbstractSingleFileUploadField, AbstractSuggestionField, AbstractTextArea, CheckBoxGroupImpl, CheckBoxImpl, ColorPickerImpl, ComboBoxImpl, CurrencyFieldImpl, DatePickerImpl, EntityLinkFieldImpl, MaskedFieldImpl, PasswordFieldImpl, RadioButtonGroupImpl, RichTextAreaImpl, SliderImpl, SourceCodeEditorImpl, TextFieldImpl, TimeFieldImpl, TwinColumnImpl, ValuePickerImpl

public abstract class AbstractField<T extends com.vaadin.ui.Component & com.vaadin.data.HasValue<P>,P,V> extends AbstractValueComponent<T,P,V> implements Field<V>
Base class for Vaadin 8 based input components.
  • Field Details

    • VALIDATORS_LIST_INITIAL_CAPACITY

      protected static final int VALIDATORS_LIST_INITIAL_CAPACITY
      See Also:
    • validators

      protected List<Validator<V>> validators
    • editable

      protected boolean editable
    • parentEditableChangeListener

      protected Subscription parentEditableChangeListener
  • Constructor Details

    • AbstractField

      public AbstractField()
  • Method Details

    • isRequired

      public boolean isRequired()
      Specified by:
      isRequired in interface Requirable
      Returns:
      whether the component must contain a non-null value
    • setRequired

      public void setRequired(boolean required)
      Description copied from interface: Requirable
      Sets whether the component must contain a non-null value.
      Specified by:
      setRequired in interface Requirable
      Parameters:
      required - required
    • setupComponentErrorProvider

      protected void setupComponentErrorProvider(boolean required, T component)
    • getErrorMessage

      @Nullable protected com.vaadin.server.ErrorMessage getErrorMessage()
    • setRequiredMessage

      public void setRequiredMessage(@Nullable String msg)
      Description copied from interface: Requirable
      Sets a message that will be displayed to user if the field is required but has null value.
      Specified by:
      setRequiredMessage in interface Requirable
      Parameters:
      msg - message
    • getRequiredMessage

      @Nullable public String getRequiredMessage()
      Specified by:
      getRequiredMessage in interface Requirable
      Returns:
      a message that will be displayed to user if the component is required but has null value
    • setParent

      public void setParent(@Nullable Component parent)
      Description copied from interface: Component
      INTERNAL.
      ComponentContainer.add(Component) is normally used for adding components to a parent and the used method will call this method implicitly.
      Specified by:
      setParent in interface Component
      Overrides:
      setParent in class AbstractComponent<T extends com.vaadin.ui.Component & com.vaadin.data.HasValue<P>>
      Parameters:
      parent - Parent component
    • isEditable

      public boolean isEditable()
      Specified by:
      isEditable in interface Component.Editable
    • setEditable

      public void setEditable(boolean editable)
      Specified by:
      setEditable in interface Component.Editable
    • setEditableToComponent

      protected void setEditableToComponent(boolean editable)
    • attachValueChangeListener

      protected void attachValueChangeListener(T component)
    • addValidator

      public void addValidator(Validator<? super V> validator)
      Description copied from interface: HasValidator
      Adds a validator instance to the component. The ValidationException must be thrown by the validator if the value is not valid.
      Specified by:
      addValidator in interface HasValidator<T extends com.vaadin.ui.Component & com.vaadin.data.HasValue<P>>
      Parameters:
      validator - a validator to add
      See Also:
    • removeValidator

      public void removeValidator(Validator<V> validator)
      Description copied from interface: HasValidator
      Removes a validator instance from the component.
      Specified by:
      removeValidator in interface HasValidator<T extends com.vaadin.ui.Component & com.vaadin.data.HasValue<P>>
      Parameters:
      validator - a validator to remove
    • getValidators

      public Collection<Validator<V>> getValidators()
      Specified by:
      getValidators in interface HasValidator<T extends com.vaadin.ui.Component & com.vaadin.data.HasValue<P>>
      Returns:
      unmodifiable collection of component validators.
    • isValid

      public boolean isValid()
      Specified by:
      isValid in interface Validatable
    • validate

      public void validate() throws ValidationException
      Specified by:
      validate in interface Validatable
      Throws:
      ValidationException
    • getDefaultRequiredMessage

      protected String getDefaultRequiredMessage()
    • triggerValidators

      protected void triggerValidators(@Nullable V value) throws ValidationFailedException
      Throws:
      ValidationFailedException
    • getDatatypeConversionErrorMsg

      @Nullable protected String getDatatypeConversionErrorMsg(@Nullable Datatype<V> datatype)