Class AbstractSliderDelegate<C extends com.vaadin.flow.component.AbstractField<?,V>,T extends Number,V extends Number>

Type Parameters:
C - component type
T - value source value type
V - component value type
All Implemented Interfaces:
ValueBindingDelegate<T>, org.springframework.beans.factory.Aware, org.springframework.context.ApplicationContextAware
Direct Known Subclasses:
DecimalSliderDelegate, IntegerSliderDelegate

public abstract class AbstractSliderDelegate<C extends com.vaadin.flow.component.AbstractField<?,V>,T extends Number,V extends Number> extends AbstractFieldDelegate<C,T,V>
  • Field Details

    • maxValidatorRegistration

      protected com.vaadin.flow.shared.Registration maxValidatorRegistration
    • minValidatorRegistration

      protected com.vaadin.flow.shared.Registration minValidatorRegistration
    • valueSet

      protected boolean valueSet
  • Constructor Details

    • AbstractSliderDelegate

      public AbstractSliderDelegate(C component)
  • Method Details

    • setMax

      public void setMax(@Nullable T max)
    • getMaxValidator

      protected abstract Validator<T> getMaxValidator(T max)
    • setMin

      public void setMin(@Nullable T min)
    • getMinValidator

      protected abstract Validator<T> getMinValidator(T min)
    • isEmpty

      public boolean isEmpty()
      Checks whether the component has no value.

      A slider always shows a number: an absent value is replaced with the minimum value, hence the component value cannot indicate the empty state. A component bound to a value source is empty when the value source value is absent, because the substituted minimum value is not propagated back, see SliderValueBinding. An unbound component is empty until a value is set to it, either by the user or programmatically.

      Returns:
      true if the component has no value, false otherwise
    • getComponentValue

      protected @Nullable T getComponentValue()

      An empty component shows the minimum value as a substitute for an absent one. That substitute is not the value of the component and is not passed to validators.

      Overrides:
      getComponentValue in class AbstractFieldDelegate<C extends com.vaadin.flow.component.AbstractField<?,V>,T extends Number,V extends Number>
    • clearValue

      public void clearValue(Runnable clearComponentValueAction)
      Clears the value of the component. A bound component clears its value source as well, instead of writing the minimum value substituted for the absent one.
      Parameters:
      clearComponentValueAction - action that clears the component value
    • onValueSet

      public void onValueSet()
      Handles a value that has been set to the component: makes sure the value reaches the value source and records that the component has a value.

      The binding cannot propagate a value the component already showed, because setting it fires no value change event.

      See Also:
    • setValueSet

      protected void setValueSet(boolean valueSet)
      Records whether a value has been set to the component. Affects an unbound component only, because for a bound one the value source is the source of truth.
      Parameters:
      valueSet - whether a value has been set to the component
      See Also:
    • updateStateOnEmptyStateChange

      protected void updateStateOnEmptyStateChange()
      Updates the validation state after the empty state of the component may have changed without a value change event.

      Entering the required error state respects UiComponentProperties.isImmediateRequiredValidationEnabled(), while leaving it does not, the same way AbstractFieldDelegate.setConversionInvalid(boolean) does it. Otherwise a required error raised by an explicit validation would never be cleared when the setting is off.

      See Also:
    • createValueBinding

      protected AbstractValueBinding<T> createValueBinding(ValueSource<T> valueSource)
      Specified by:
      createValueBinding in class AbstractValueComponentDelegate<C extends com.vaadin.flow.component.AbstractField<?,V>,T extends Number,V extends Number>