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 ClassesModifier and TypeClassDescriptionstatic final classThis 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
FieldsModifier and TypeFieldDescriptionstatic final StringClass name used whensetRequiredIndicatorVisible(boolean)is set totrue. -
Constructor Summary
ConstructorsConstructorDescriptionCreates 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 TypeMethodDescriptioncom.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.getValue()booleanbooleanvoidsetReadOnly(boolean b) voidsetRequiredIndicatorVisible(boolean visible) voidMethods inherited from class com.vaadin.flow.component.Composite
getChildren, getContent, getElement, initContentMethods 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, setVisibleMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.vaadin.flow.component.AttachNotifier
addAttachListenerMethods inherited from interface com.vaadin.flow.component.DetachNotifier
addDetachListenerMethods inherited from interface com.vaadin.flow.component.HasElement
getElementMethods inherited from interface com.vaadin.flow.component.HasStyle
addClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassNameMethods inherited from interface com.vaadin.flow.component.HasValue
clear, getEmptyValue, getOptionalValue, isEmptyMethods inherited from interface org.vaadin.miki.markers.WithIdMixin
withIdMethods inherited from interface org.vaadin.miki.markers.WithValueMixin
withValue
-
Field Details
-
REQUIRED_INDICATOR_VISIBLE
Class name used whensetRequiredIndicatorVisible(boolean)is set totrue.- See Also:
-
-
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 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 Details
-
fireValueChangeEvent
protected void fireValueChangeEvent(boolean currentValue) Fires value change to registered listeners.- Parameters:
currentValue- Current value of the field.
-
setValue
- Specified by:
setValuein interfacecom.vaadin.flow.component.HasValue<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<ObservedField,Boolean>, 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>
-