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:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classObservedField.ObservedFieldElementThis class gives a nice tag name toObservedFieldin 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 StringREQUIRED_INDICATOR_VISIBLEClass name used whensetRequiredIndicatorVisible(boolean)is set totrue.
-
Constructor Summary
Constructors Constructor Description ObservedField()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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description com.vaadin.flow.shared.RegistrationaddValueChangeListener(com.vaadin.flow.component.HasValue.ValueChangeListener<? super com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<ObservedField,Boolean>> valueChangeListener)protected voidfireValueChangeEvent(boolean currentValue)Fires value change to registered listeners.BooleangetValue()booleanisReadOnly()booleanisRequiredIndicatorVisible()voidsetReadOnly(boolean b)voidsetRequiredIndicatorVisible(boolean visible)voidsetValue(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, 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.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 Detail
-
REQUIRED_INDICATOR_VISIBLE
public static final String REQUIRED_INDICATOR_VISIBLE
Class name used whensetRequiredIndicatorVisible(boolean)is set totrue.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
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 usingaddValueChangeListener(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 usingaddValueChangeListener(ValueChangeListener).- Parameters:
onlyToggleOnce- Whether or not to trigger value change only once.listener- Listener to add.
-
-
Method Detail
-
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:
setValuein interfacecom.vaadin.flow.component.HasValue<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<ObservedField,Boolean>,Boolean>
-
getValue
public Boolean getValue()
- Specified by:
getValuein interfacecom.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:
addValueChangeListenerin interfacecom.vaadin.flow.component.HasValue<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<ObservedField,Boolean>,Boolean>
-
setReadOnly
public void setReadOnly(boolean b)
- Specified by:
setReadOnlyin interfacecom.vaadin.flow.component.HasValue<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<ObservedField,Boolean>,Boolean>
-
isReadOnly
public boolean isReadOnly()
- Specified by:
isReadOnlyin interfacecom.vaadin.flow.component.HasValue<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<ObservedField,Boolean>,Boolean>
-
setRequiredIndicatorVisible
public void setRequiredIndicatorVisible(boolean visible)
- Specified by:
setRequiredIndicatorVisiblein interfacecom.vaadin.flow.component.HasValue<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<ObservedField,Boolean>,Boolean>
-
isRequiredIndicatorVisible
public boolean isRequiredIndicatorVisible()
- Specified by:
isRequiredIndicatorVisiblein interfacecom.vaadin.flow.component.HasValue<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<ObservedField,Boolean>,Boolean>
-
-