C
- the source type for value change eventsT
- the value typepublic class AbstractSinglePropertyField<C extends AbstractField<C,T>,T> extends AbstractField<C,T>
AbstractField.ComponentValueChangeEvent<C extends Component,V>
HasValue.ValueChangeEvent<V>, HasValue.ValueChangeListener<E extends HasValue.ValueChangeEvent<?>>
Constructor and Description |
---|
AbstractSinglePropertyField(String propertyName,
T defaultValue,
boolean acceptNullValues)
Creates a new field that uses a property value without any conversion.
|
AbstractSinglePropertyField(String propertyName,
T defaultValue,
Class<P> elementPropertyType,
SerializableBiFunction<C,P,T> presentationToModel,
SerializableBiFunction<C,T,P> modelToPresentation)
Creates a new field that uses a property value with the given contextual
converters for producing a model value.
|
AbstractSinglePropertyField(String propertyName,
T defaultValue,
Class<P> elementPropertyType,
SerializableFunction<P,T> presentationToModel,
SerializableFunction<T,P> modelToPresentation)
Creates a new field that uses a property value with the given stateless
converters for producing a model value.
|
Modifier and Type | Method and Description |
---|---|
protected DomListenerRegistration |
getSynchronizationRegistration()
Returns the registration of the DOM event listener that synchronizes the
property value.
|
protected boolean |
hasValidValue()
Checks whether the element property has a value that can be converted to
the model type.
|
protected void |
setPresentationValue(T newPresentationValue)
Updates the presentation of this field to display the provided value.
|
protected void |
setSynchronizedEvent(String synchronizedEvent)
Sets the name of the DOM event for which property values are synchronized
from the client to the server.
|
addValueChangeListener, getEmptyValue, getValue, isEmpty, setModelValue, setValue, valueEquals
addListener, fireEvent, from, get, getChildren, getElement, getEventBus, getId, getLocale, getParent, getTranslation, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onAttach, onDetach, onEnabledStateChanged, set, setElement, setId, setVisible
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
isReadOnly, isRequiredIndicatorVisible, setReadOnly, setRequiredIndicatorVisible
clear, getOptionalValue
isEnabled, setEnabled
getElement
addAttachListener
addDetachListener
public AbstractSinglePropertyField(String propertyName, T defaultValue, boolean acceptNullValues)
The value type of the class must be one of the types that can be written as an element property value: String, Integer, Double or Boolean.
propertyName
- the name of the element property to usedefaultValue
- the default value to use if the property isn't definedacceptNullValues
- if true
, an exception will be thrown if the model
value is set to null
; if false
the
property will be removed when the model value is set to
null
public AbstractSinglePropertyField(String propertyName, T defaultValue, Class<P> elementPropertyType, SerializableFunction<P,T> presentationToModel, SerializableFunction<T,P> modelToPresentation)
The property type must be one of the types that can be written as an element property value: String, Integer, Double or Boolean.
P
- the property typepropertyName
- the name of the element property to usedefaultValue
- the default value to use if the property isn't definedelementPropertyType
- the type of the element propertypresentationToModel
- a function that converts a property value to a model valuemodelToPresentation
- a function that converts a model value to a property valuepublic AbstractSinglePropertyField(String propertyName, T defaultValue, Class<P> elementPropertyType, SerializableBiFunction<C,P,T> presentationToModel, SerializableBiFunction<C,T,P> modelToPresentation)
The property type must be one of the types that can be written as an element property value: String, Integer, Double or Boolean.
P
- the property typepropertyName
- the name of the element property to usedefaultValue
- the default value to use if the property isn't definedelementPropertyType
- the type of the element propertypresentationToModel
- a function that accepts this component and a property value
and returns a model valuemodelToPresentation
- a function that accepts this component and a model value and
returns a property valueprotected void setSynchronizedEvent(String synchronizedEvent)
-changed
appended. This means that if the property
name is value
, then the event default name is
value-changed
.synchronizedEvent
- the property name to synchronize, or null
to
disable property synchronizationElement.addPropertyChangeListener(String, String,
PropertyChangeListener)
,
getSynchronizationRegistration()
protected DomListenerRegistration getSynchronizationRegistration()
setSynchronizedEvent(String)
.null
if property synchronization
is disabledprotected boolean hasValidValue()
false
. The default implementation always
return true
.true
if the element property value can be converted
to the model type; otherwise false
protected void setPresentationValue(T newPresentationValue)
AbstractField
If AbstractField.setModelValue(Object, boolean)
is called from within this
method, the value of the last invocation will be used as the model value
instead of the value passed to this method. In this case
AbstractField.setPresentationValue(Object)
will not be called again. Changing
the provided value might be useful if the provided value is sanitized.
See AbstractField
for an overall description on the difference
between model values and presentation values.
setPresentationValue
in class AbstractField<C extends AbstractField<C,T>,T>
newPresentationValue
- the new value to showCopyright © 2023. All rights reserved.