Class ReadOnlyHasValue<V>

java.lang.Object
com.vaadin.flow.data.binder.ReadOnlyHasValue<V>
Type Parameters:
V - the value type
All Implemented Interfaces:
com.vaadin.flow.component.HasValue<com.vaadin.flow.component.HasValue.ValueChangeEvent<V>,V>, Serializable

public class ReadOnlyHasValue<V> extends Object implements com.vaadin.flow.component.HasValue<com.vaadin.flow.component.HasValue.ValueChangeEvent<V>,V>, Serializable
Generic 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);
 
Since:
1.0
See Also:
  • Nested Class Summary

    Nested classes/interfaces inherited from interface com.vaadin.flow.component.HasValue

    com.vaadin.flow.component.HasValue.ValueChangeEvent<V>, com.vaadin.flow.component.HasValue.ValueChangeListener<E extends com.vaadin.flow.component.HasValue.ValueChangeEvent<?>>
  • Constructor Summary

    Constructors
    Constructor
    Description
    ReadOnlyHasValue(com.vaadin.flow.function.SerializableConsumer<V> valueProcessor)
    Creates new ReadOnlyHasValue with null as an empty value.
    ReadOnlyHasValue(com.vaadin.flow.function.SerializableConsumer<V> valueProcessor, V emptyValue)
    Creates new ReadOnlyHasValue
  • Method Summary

    Modifier and Type
    Method
    Description
    com.vaadin.flow.shared.Registration
    addValueChangeListener(com.vaadin.flow.component.HasValue.ValueChangeListener<? super com.vaadin.flow.component.HasValue.ValueChangeEvent<V>> listener)
     
     
     
    boolean
     
    boolean
     
    void
    setReadOnly(boolean readOnly)
     
    void
    setRequiredIndicatorVisible(boolean requiredIndicatorVisible)
     
    void
    setValue(V value)
     

    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.HasValue

    bindValue, clear, getOptionalValue, isEmpty
  • Constructor Details

    • ReadOnlyHasValue

      public ReadOnlyHasValue(com.vaadin.flow.function.SerializableConsumer<V> valueProcessor, V emptyValue)
      Creates new ReadOnlyHasValue
      Parameters:
      valueProcessor - the value valueProcessor, e.g. a setter for displaying the value in a component
      emptyValue - the value to be used as empty, null by default
    • ReadOnlyHasValue

      public ReadOnlyHasValue(com.vaadin.flow.function.SerializableConsumer<V> valueProcessor)
      Creates new ReadOnlyHasValue with null as an empty value.
      Parameters:
      valueProcessor - the value valueProcessor, e.g. a setter for displaying the value in a component
  • Method Details

    • setValue

      public void setValue(V value)
      Specified by:
      setValue in interface com.vaadin.flow.component.HasValue<com.vaadin.flow.component.HasValue.ValueChangeEvent<V>,V>
    • getValue

      public V getValue()
      Specified by:
      getValue in interface com.vaadin.flow.component.HasValue<com.vaadin.flow.component.HasValue.ValueChangeEvent<V>,V>
    • addValueChangeListener

      public com.vaadin.flow.shared.Registration addValueChangeListener(com.vaadin.flow.component.HasValue.ValueChangeListener<? super com.vaadin.flow.component.HasValue.ValueChangeEvent<V>> listener)
      Specified by:
      addValueChangeListener in interface com.vaadin.flow.component.HasValue<com.vaadin.flow.component.HasValue.ValueChangeEvent<V>,V>
    • isRequiredIndicatorVisible

      public boolean isRequiredIndicatorVisible()
      Specified by:
      isRequiredIndicatorVisible in interface com.vaadin.flow.component.HasValue<com.vaadin.flow.component.HasValue.ValueChangeEvent<V>,V>
    • setRequiredIndicatorVisible

      public void setRequiredIndicatorVisible(boolean requiredIndicatorVisible)
      Specified by:
      setRequiredIndicatorVisible in interface com.vaadin.flow.component.HasValue<com.vaadin.flow.component.HasValue.ValueChangeEvent<V>,V>
    • setReadOnly

      public void setReadOnly(boolean readOnly)
      Specified by:
      setReadOnly in interface com.vaadin.flow.component.HasValue<com.vaadin.flow.component.HasValue.ValueChangeEvent<V>,V>
    • isReadOnly

      public boolean isReadOnly()
      Specified by:
      isReadOnly in interface com.vaadin.flow.component.HasValue<com.vaadin.flow.component.HasValue.ValueChangeEvent<V>,V>
    • getEmptyValue

      public V getEmptyValue()
      Specified by:
      getEmptyValue in interface com.vaadin.flow.component.HasValue<com.vaadin.flow.component.HasValue.ValueChangeEvent<V>,V>