com.vaadin.data.

Class ReadOnlyHasValue<V>

  • Type Parameters:

    V - the value type

    All Implemented Interfaces:

    HasValue<V>, Serializable

    public class ReadOnlyHasValue<V>
    extends Object
    implements HasValue<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::setCaption);
     binder.forField(hasValue).bind(SomeBean::getName);
     

    Since:

    8.4

    See Also:

    Serialized Form

    • Method Detail

      • setValue

        public void setValue​(V value)

        Description copied from interface: HasValue

        Sets the value of this object. If the new value is not equal to getValue(), 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.

        Specified by:

        setValue in interface HasValue<V>

        Parameters:

        value - the new value

      • getValue

        public V getValue()

        Description copied from interface: HasValue

        Returns the current value of this object.

        Implementation note: the implementing class should document whether null values may be returned or not.

        Specified by:

        getValue in interface HasValue<V>

        Returns:

        the current value

      • addValueChangeListener

        public Registration addValueChangeListener​(HasValue.ValueChangeListener<V> listener)

        Description copied from interface: HasValue

        Adds a value change listener. The listener is called when the value of this HasValue is changed either by the user or programmatically.

        Specified by:

        addValueChangeListener in interface HasValue<V>

        Parameters:

        listener - the value change listener, not null

        Returns:

        a registration for the listener

      • isRequiredIndicatorVisible

        public boolean isRequiredIndicatorVisible()

        Description copied from interface: HasValue

        Checks whether the required indicator is visible.

        Specified by:

        isRequiredIndicatorVisible in interface HasValue<V>

        Returns:

        true if visible, false if not

      • setRequiredIndicatorVisible

        public void setRequiredIndicatorVisible​(boolean requiredIndicatorVisible)

        Description copied from interface: HasValue

        Sets the required indicator visible or not.

        If set visible, it is visually indicated in the user interface.

        Specified by:

        setRequiredIndicatorVisible in interface HasValue<V>

        Parameters:

        requiredIndicatorVisible - true to make the required indicator visible, false if not

      • setReadOnly

        public void setReadOnly​(boolean readOnly)

        Description copied from interface: HasValue

        Sets the read-only mode of this HasValue 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.

        Specified by:

        setReadOnly in interface HasValue<V>

        Parameters:

        readOnly - a boolean value specifying whether the component is put read-only mode or not

      • isReadOnly

        public boolean isReadOnly()

        Description copied from interface: HasValue

        Returns whether this HasValue is in read-only mode or not.

        Specified by:

        isReadOnly in interface HasValue<V>

        Returns:

        false if the user can modify the value, true if not.