Class ObservedField

java.lang.Object
com.vaadin.flow.component.Component
com.vaadin.flow.component.Composite<ObservedField.ObservedFieldElement>
org.vaadin.miki.superfields.lazyload.ObservedField
All Implemented Interfaces:
com.vaadin.flow.component.AttachNotifier, com.vaadin.flow.component.DetachNotifier, com.vaadin.flow.component.HasElement, com.vaadin.flow.component.HasStyle, com.vaadin.flow.component.HasValue<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<ObservedField,Boolean>,Boolean>, Serializable, HasId, WithIdMixin<ObservedField>, WithValueMixin<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<ObservedField,Boolean>,Boolean,ObservedField>

public class ObservedField extends com.vaadin.flow.component.Composite<ObservedField.ObservedFieldElement> implements com.vaadin.flow.component.HasStyle, WithValueMixin<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<ObservedField,Boolean>,Boolean,ObservedField>, WithIdMixin<ObservedField>
A field that changes value depending on whether or not it is currently shown on screen.
Since:
2020-04-24
Author:
miki
See Also:
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static final class 
    This class gives a nice tag name to ObservedField in the browser.

    Nested classes/interfaces inherited from interface com.vaadin.flow.component.HasValue

    com.vaadin.flow.component.HasValue.ValueChangeEvent<V extends Object>, com.vaadin.flow.component.HasValue.ValueChangeListener<E extends com.vaadin.flow.component.HasValue.ValueChangeEvent<?>>
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    Class name used when setRequiredIndicatorVisible(boolean) is set to true.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a field that will set its value to whether or not it is currently shown on screen.
    ObservedField(boolean onlyToggleOnce)
    Creates a field that will optionally only toggle value once, on first showing.
    ObservedField(boolean onlyToggleOnce, com.vaadin.flow.component.HasValue.ValueChangeListener<com.vaadin.flow.component.HasValue.ValueChangeEvent<Boolean>> listener)
    Creates a field that will optionally only toggle value once, on first showing.
    ObservedField(com.vaadin.flow.component.HasValue.ValueChangeListener<com.vaadin.flow.component.HasValue.ValueChangeEvent<Boolean>> listener)
    Creates a field that will set its value to whether or not it is currently shown on screen.
  • Method Summary

    Modifier and Type
    Method
    Description
    com.vaadin.flow.shared.Registration
    addValueChangeListener(com.vaadin.flow.component.HasValue.ValueChangeListener<? super com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<ObservedField,Boolean>> valueChangeListener)
     
    protected void
    fireValueChangeEvent(boolean currentValue)
    Fires value change to registered listeners.
     
    boolean
     
    boolean
     
    void
    setReadOnly(boolean b)
     
    void
    setRequiredIndicatorVisible(boolean visible)
     
    void
    setValue(Boolean aBoolean)
     

    Methods inherited from class com.vaadin.flow.component.Composite

    getChildren, getContent, getElement, initContent

    Methods inherited from class com.vaadin.flow.component.Component

    addListener, findAncestor, fireEvent, from, get, getEventBus, getId, getListeners, getLocale, getParent, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onAttach, onDetach, onEnabledStateChanged, removeFromParent, scrollIntoView, scrollIntoView, set, setElement, setId, setVisible

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface com.vaadin.flow.component.AttachNotifier

    addAttachListener

    Methods inherited from interface com.vaadin.flow.component.DetachNotifier

    addDetachListener

    Methods inherited from interface com.vaadin.flow.component.HasElement

    getElement

    Methods inherited from interface org.vaadin.miki.markers.HasId

    getId, setId

    Methods inherited from interface com.vaadin.flow.component.HasStyle

    addClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassName

    Methods inherited from interface com.vaadin.flow.component.HasValue

    clear, getEmptyValue, getOptionalValue, isEmpty

    Methods inherited from interface org.vaadin.miki.markers.WithIdMixin

    withId

    Methods inherited from interface org.vaadin.miki.markers.WithValueMixin

    withValue
  • Field Details

  • Constructor Details

    • ObservedField

      public ObservedField()
      Creates a field that will set its value to whether or not it is currently shown on screen.
    • ObservedField

      public ObservedField(com.vaadin.flow.component.HasValue.ValueChangeListener<com.vaadin.flow.component.HasValue.ValueChangeEvent<Boolean>> listener)
      Creates a field that will set its value to whether or not it is currently shown on screen. It will also register given listener using addValueChangeListener(ValueChangeListener).
      Parameters:
      listener - Listener to add.
    • ObservedField

      public ObservedField(boolean onlyToggleOnce)
      Creates a field that will optionally only toggle value once, on first showing.
      Parameters:
      onlyToggleOnce - Whether or not to trigger value change only once.
    • ObservedField

      public ObservedField(boolean onlyToggleOnce, com.vaadin.flow.component.HasValue.ValueChangeListener<com.vaadin.flow.component.HasValue.ValueChangeEvent<Boolean>> listener)
      Creates a field that will optionally only toggle value once, on first showing. It will also register given listener using addValueChangeListener(ValueChangeListener).
      Parameters:
      onlyToggleOnce - Whether or not to trigger value change only once.
      listener - Listener to add.
  • Method Details

    • fireValueChangeEvent

      protected void fireValueChangeEvent(boolean currentValue)
      Fires value change to registered listeners.
      Parameters:
      currentValue - Current value of the field.
    • setValue

      public void setValue(Boolean aBoolean)
      Specified by:
      setValue in interface com.vaadin.flow.component.HasValue<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<ObservedField,Boolean>,Boolean>
    • getValue

      public Boolean getValue()
      Specified by:
      getValue in interface com.vaadin.flow.component.HasValue<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<ObservedField,Boolean>,Boolean>
    • addValueChangeListener

      public com.vaadin.flow.shared.Registration addValueChangeListener(com.vaadin.flow.component.HasValue.ValueChangeListener<? super com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<ObservedField,Boolean>> valueChangeListener)
      Specified by:
      addValueChangeListener in interface com.vaadin.flow.component.HasValue<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<ObservedField,Boolean>,Boolean>
    • setReadOnly

      public void setReadOnly(boolean b)
      Specified by:
      setReadOnly in interface com.vaadin.flow.component.HasValue<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<ObservedField,Boolean>,Boolean>
    • isReadOnly

      public boolean isReadOnly()
      Specified by:
      isReadOnly in interface com.vaadin.flow.component.HasValue<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<ObservedField,Boolean>,Boolean>
    • setRequiredIndicatorVisible

      public void setRequiredIndicatorVisible(boolean visible)
      Specified by:
      setRequiredIndicatorVisible in interface com.vaadin.flow.component.HasValue<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<ObservedField,Boolean>,Boolean>
    • isRequiredIndicatorVisible

      public boolean isRequiredIndicatorVisible()
      Specified by:
      isRequiredIndicatorVisible in interface com.vaadin.flow.component.HasValue<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<ObservedField,Boolean>,Boolean>