V - the value typepublic class ReadOnlyHasValue<V> extends Object implements HasValue<HasValue.ValueChangeEvent<V>,V>, Serializable
HasValue to use any type of component with Vaadin data
binding.
Example:
Label label = new Label(); ReadOnlyHasValue<String> hasValue = new ReadOnlyHasValue<>(label::setText); binder.forField(hasValue).bind(SomeBean::getName, null);
HasValue.ValueChangeEvent<V>, HasValue.ValueChangeListener<E extends HasValue.ValueChangeEvent<?>>| Constructor and Description |
|---|
ReadOnlyHasValue(SerializableConsumer<V> valueProcessor)
Creates new
ReadOnlyHasValue with null as an empty value. |
ReadOnlyHasValue(SerializableConsumer<V> valueProcessor,
V emptyValue)
Creates new
ReadOnlyHasValue |
| Modifier and Type | Method and Description |
|---|---|
Registration |
addValueChangeListener(HasValue.ValueChangeListener<? super HasValue.ValueChangeEvent<V>> listener)
Adds a value change listener.
|
V |
getEmptyValue()
Returns the value that represents an empty value.
|
V |
getValue()
Returns the current value of this object.
|
boolean |
isReadOnly()
Returns whether this
HasValue is in read-only mode or not. |
boolean |
isRequiredIndicatorVisible()
Checks whether the required indicator is visible.
|
void |
setReadOnly(boolean readOnly)
Sets the read-only mode of this
HasValue to given mode. |
void |
setRequiredIndicatorVisible(boolean requiredIndicatorVisible)
Sets the required indicator visible or not.
|
void |
setValue(V value)
Sets the value of this object.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitclear, getOptionalValue, isEmptypublic ReadOnlyHasValue(SerializableConsumer<V> valueProcessor, V emptyValue)
ReadOnlyHasValuevalueProcessor - the value valueProcessor, e.g. a setter for displaying the
value in a componentemptyValue - the value to be used as empty, null by defaultpublic ReadOnlyHasValue(SerializableConsumer<V> valueProcessor)
ReadOnlyHasValue with null as an empty value.valueProcessor - the value valueProcessor, e.g. a setter for displaying the
value in a componentpublic void setValue(V value)
HasValuegetValue(), fires a value change event. May throw
IllegalArgumentException if the value is not acceptable.
Implementation note: the implementing class should document
whether null values are accepted or not, and override
HasValue.getEmptyValue() if the empty value is not null.
setValue in interface HasValue<HasValue.ValueChangeEvent<V>,V>value - the new valuepublic V getValue()
HasValue
Implementation note: the implementing class should document
whether null values may be returned or not, and override
HasValue.getEmptyValue() if the empty value is not null.
getValue in interface HasValue<HasValue.ValueChangeEvent<V>,V>public Registration addValueChangeListener(HasValue.ValueChangeListener<? super HasValue.ValueChangeEvent<V>> listener)
HasValueHasValue is changed either by the user or programmatically.addValueChangeListener in interface HasValue<HasValue.ValueChangeEvent<V>,V>listener - the value change listener, not nullpublic boolean isRequiredIndicatorVisible()
HasValueisRequiredIndicatorVisible in interface HasValue<HasValue.ValueChangeEvent<V>,V>true if visible, false if notpublic void setRequiredIndicatorVisible(boolean requiredIndicatorVisible)
HasValueIf set visible, it is visually indicated in the user interface.
The method is intended to be used with Binder which does
server-side validation. In case HTML element has its own (client-side)
validation it should be disabled when
setRequiredIndicatorVisible(true) is called and re-enabled
back on setRequiredIndicatorVisible(false). It's
responsibility of each component implementation to follow the contract so
that the method call doesn't do anything else than show/hide the
"required" indication. Usually components provide their own
setRequired method which should be called in case the
client-side validation is required.
setRequiredIndicatorVisible in interface HasValue<HasValue.ValueChangeEvent<V>,V>requiredIndicatorVisible - true to make the required indicator visible,
false if notpublic void setReadOnly(boolean readOnly)
HasValueHasValue to given mode. The user
can't change the value when in read-only mode.
A HasValue with a visual component in read-only mode typically
looks visually different to signal to the user that the value cannot be
edited.
setReadOnly in interface HasValue<HasValue.ValueChangeEvent<V>,V>readOnly - a boolean value specifying whether the component is put
read-only mode or notpublic boolean isReadOnly()
HasValueHasValue is in read-only mode or not.isReadOnly in interface HasValue<HasValue.ValueChangeEvent<V>,V>false if the user can modify the value, true if
not.public V getEmptyValue()
HasValue
By default HasValue is expected to support null as empty
values. Specific implementations might not support this.
getEmptyValue in interface HasValue<HasValue.ValueChangeEvent<V>,V>Copyright © 2025. All rights reserved.