Class AbstractFieldSupport<C extends Component & HasValue<AbstractField.ComponentValueChangeEvent<C,T>,T>,T>
- Type Parameters:
C- the value change source typeT- the value type
- All Implemented Interfaces:
Serializable
AbstractField but
not in AbstractCompositeField, or vice versa.
For internal use only. May be renamed or removed in a future release.
- Since:
- 1.0
- Author:
- Vaadin Ltd
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionAbstractFieldSupport(C component, T defaultValue, SerializableBiPredicate<T, T> valueEquals, SerializableConsumer<T> setPresentationValue) Creates a new field support. -
Method Summary
Modifier and TypeMethodDescriptionaddValueChangeListener(HasValue.ValueChangeListener<? super AbstractField.ComponentValueChangeEvent<C, T>> listener) voidbindValue(Signal<T> valueSignal, SerializableConsumer<T> writeCallback) Binds aSignal's value to the value state of the field and keeps the state synchronized with the signal value while the element is in attached state.Delegate method forHasValue.getEmptyValue().getValue()Delegate method forHasValue.getValue().voidsetModelValue(T newModelValue, boolean fromClient) Delegate method corresponding toAbstractField.setModelValue(Object, boolean).voidDelegate method forHasValue.setValue(Object).booleanvalueEquals(T value1, T value2) Delegate method corresponding toAbstractField.valueEquals(Object, Object).
-
Constructor Details
-
AbstractFieldSupport
public AbstractFieldSupport(C component, T defaultValue, SerializableBiPredicate<T, T> valueEquals, SerializableConsumer<T> setPresentationValue) Creates a new field support.- Parameters:
component- the owning field componentdefaultValue- the default field valuevalueEquals- a callback for comparing valuessetPresentationValue- a callback for setting presentation values
-
-
Method Details
-
addValueChangeListener
public Registration addValueChangeListener(HasValue.ValueChangeListener<? super AbstractField.ComponentValueChangeEvent<C, T>> listener) Delegate method forHasValue.addValueChangeListener(com.vaadin.flow.component.HasValue.ValueChangeListener)- Parameters:
listener- the listener to add- Returns:
- a registration for the listener
-
getValue
Delegate method forHasValue.getValue().- Returns:
- the field value
-
getEmptyValue
Delegate method forHasValue.getEmptyValue().- Returns:
- the empty value of this field
-
setValue
Delegate method forHasValue.setValue(Object).- Parameters:
value- the value to set
-
valueEquals
Delegate method corresponding toAbstractField.valueEquals(Object, Object).- Parameters:
value1- the first instancevalue2- the second instance- Returns:
trueif the instances are equal; otherwisefalse
-
setModelValue
Delegate method corresponding toAbstractField.setModelValue(Object, boolean).- Parameters:
newModelValue- the new internal value to usefromClient-trueif the new value originates from the client; otherwisefalse
-
bindValue
Binds aSignal's value to the value state of the field and keeps the state synchronized with the signal value while the element is in attached state. When the element is in detached state, signal value changes have no effect.While a Signal is bound to a value state, any attempt to bind a new Signal while one is already bound throws
BindingActiveException.While a Signal is bound to a value state and the element is in attached state, setting the value with
setValue(Object),setModelValue(Object, boolean), or when a change originates from the client, will invoke the write callback to propagate the value back. After the callback, the signal is re-consulted and if its value differs from what was being set, the new value is ignored and the signal's updated value is used instead, i.e. in cases where write callback has `signal.set("different")`, whereas a value being set is "a new value", the "different" value wins.If the write callback is
null, the binding is read-only and any attempt to set the value while attached will throw anIllegalStateException.- Parameters:
valueSignal- the signal to bind, notnullwriteCallback- the callback to propagate value changes back, ornullfor a read-only binding- Throws:
BindingActiveException- thrown when there is already an existing binding- See Also:
-