com.holonplatform.vaadin.flow.components

## Interface PropertyInputGroup

- All Superinterfaces:
    BoundComponentGroup<com.holonplatform.core.property.Property<?>,Input<?>>, ComponentGroup<Input<?>>, HasPropertySet<com.holonplatform.core.property.Property<?>>, Serializable, Validatable, ValueHolder<com.holonplatform.core.property.PropertyBox,GroupValueChangeEvent<com.holonplatform.core.property.PropertyBox,com.holonplatform.core.property.Property<?>,Input<?>,PropertyInputGroup>>
  All Known Subinterfaces:
    PropertyInputForm

      public interface PropertyInputGroup
      extends BoundComponentGroup<com.holonplatform.core.property.Property<?>,Input<?>>, ValueHolder<com.holonplatform.core.property.PropertyBox,GroupValueChangeEvent<com.holonplatform.core.property.PropertyBox,com.holonplatform.core.property.Property<?>,Input<?>,PropertyInputGroup>>, Validatable

  A `BoundComponentGroup` which handles `Input` elements type and uses a `Property` set to bind and identify the elements within the group.

  As a `ValueHolder`, allows to manage the overall group elements value, represented by a `PropertyBox` instance.

  The `refresh()` and `refresh(Property)` methods can be used to refresh the group elements values, for example to recalculate any virtual group element value which depends on other elements value.

  The `PropertyInputGroup` is `Validatable` and supports `Validator` registration both for the single group element and for the overall group value. See the `InputGroupConfigurator.PropertySetInputGroupConfigurator.withValidator(Property, Validator)` and `InputGroupConfigurator.withValidator(Validator)` methods.

  By default, the `Input` components to bind to each property are obtained using the `PropertyRenderer`s registered in the context `PropertyRendererRegistry`, if available. The `bind(...)` methods of the `PropertyInputGroupBuilder` can be used to provided a specific renderer or `Input` of one or more group property.

  The convenience methods `setEnabled(boolean)` and `setReadOnly(boolean)` can be used to change the enabled / read-only state for all the property bound `Input`s.

  Since:
    5.2.0

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from interface com.holonplatform.vaadin.flow.components.BoundComponentGroup

      `BoundComponentGroup.Binding<P,C extends HasComponent>`

    - ### Nested classes/interfaces inherited from interface com.holonplatform.vaadin.flow.components.ValueHolder

      `ValueHolder.ValueChangeEvent<V>, ValueHolder.ValueChangeListener<V,E extends ValueHolder.ValueChangeEvent<V>>`

  - ### Method Summary

    All Methods Static Methods Instance Methods Abstract Methods Default Methods
    Modifier and Type | Method and Description
    --- | ---
    `static <P extends com.holonplatform.core.property.Property> PropertyInputGroupBuilder` | `builder(Iterable<P> properties)` Get a `PropertyInputGroupBuilder` to create and setup a `PropertyInputGroup`.
    `static PropertyInputGroupBuilder` | `builder(com.holonplatform.core.property.Property<?>... properties)` Get a `PropertyInputGroupBuilder` to create and setup a `PropertyInputGroup`.
    `<T> Optional<Input<T>>` | `getInput(com.holonplatform.core.property.Property<T> property)` Get the `Input` bound to the given `property`, if available.
    `com.holonplatform.core.property.PropertyBox` | `getValue()` Get the current property values collected into a `PropertyBox`, using the group configured properties as property set.
    `com.holonplatform.core.property.PropertyBox` | `getValue(boolean validate)` Get the current property values collected into a `PropertyBox`, using the group configured properties as property set.
    `Optional<com.holonplatform.core.property.PropertyBox>` | `getValueIfValid()` Get the current property values collected into a `PropertyBox`, using the group configured properties as property set, only if the property bound `Input`s and this `PropertyInputGroup` are valid For each property with a bound `Input` component, the property value is obtained from the `Input` component through the `ValueHolder.getValue()` method.
    `void` | `refresh()` Refresh the value of all available `Input`s, using current value.
    `<T> boolean` | `refresh(com.holonplatform.core.property.Property<T> property)` Refresh the value of the `Input` bound to given `property`, using current value.
    `default <T> Input<T>` | `requireInput(com.holonplatform.core.property.Property<T> property)` Get the `Input` bound to the given `property`, throwing a `Property.PropertyNotFoundException` if not available.
    `void` | `setEnabled(boolean enabled)` Updates the enabled state of all the group inputs.
    `void` | `setReadOnly(boolean readOnly)` Set the read-only mode for all the group inputs.
    `void` | `setValue(com.holonplatform.core.property.PropertyBox value)` Set the current property values using a `PropertyBox`, loading the values to the available property bound `Input`s through the `ValueHolder.setValue(Object)` method.
    `void` | `setValue(com.holonplatform.core.property.PropertyBox value, boolean validate)` Set the current property values using a `PropertyBox`, loading the values to the available property bound `Input`s through the `ValueHolder.setValue(Object)` method.
    `void` | `validate()` Checks the validity of each input component of the group and of the group value against every registered validator, if any.

    - ### Methods inherited from interface com.holonplatform.vaadin.flow.components.BoundComponentGroup

      `getBindings, getElement, requireElement`

    - ### Methods inherited from interface com.holonplatform.vaadin.flow.components.ComponentGroup

      `getComponents, getElements`

    - ### Methods inherited from interface com.holonplatform.vaadin.flow.components.HasPropertySet

      `getProperties, hasProperty`

    - ### Methods inherited from interface com.holonplatform.vaadin.flow.components.ValueHolder

      `addValueChangeListener, clear, getEmptyValue, getValueIfPresent, isEmpty`

    - ### Methods inherited from interface com.holonplatform.vaadin.flow.components.Validatable

      `adapt, adapt, adapt, adapt, adapt, isValid`

- - ### Method Detail

    - #### getInput

          <T> Optional<Input<T>> getInput(com.holonplatform.core.property.Property<T> property)

      Get the `Input` bound to the given `property`, if available.
      Type Parameters:
        `T` - Property type
      Parameters:
        `property` - The property which identifies the `Input` within the group (not null)
      Returns:
        Optional `Input` bound to the given `property`

    - #### requireInput

          default <T> Input<T> requireInput(com.holonplatform.core.property.Property<T> property)

      Get the `Input` bound to the given `property`, throwing a `Property.PropertyNotFoundException` if not available.
      Type Parameters:
        `T` - Property type
      Parameters:
        `property` - The property which identifies the `Input` within the group (not null)
      Returns:
        The `Input` bound to the given `property`
      Throws:
        `com.holonplatform.core.property.Property.PropertyNotFoundException` - If no `Input` is bound to given property

    - #### refresh

          void refresh()

      Refresh the value of all available `Input`s, using current value.

      Each input value will be replaced by the value of the `Property` to which the input is bound, obtained from the current `PropertyBox` value.

    - #### refresh

          <T> boolean refresh(com.holonplatform.core.property.Property<T> property)

      Refresh the value of the `Input` bound to given `property`, using current value.

      The input value will be replaced by the value of the `Property` to which the input is bound, obtained from the current `PropertyBox` value.

      Type Parameters:
        `T` - Property type
      Parameters:
        `property` - The property for which to refresh the bound `Input` (not null)
      Returns:
        `true` if an `Input` bound to given property is available, `false` otherwise

    - #### getValue

          com.holonplatform.core.property.PropertyBox getValue(boolean validate)

      Get the current property values collected into a `PropertyBox`, using the group configured properties as property set.

      For each property with a bound `Input` component, the property value is obtained from the `Input` component through the `ValueHolder.getValue()` method.

      Parameters:
        `validate` - `true` to check the validity of the property bound `Input`s and of this `PropertyInputGroup` before returing the value, throwing a `Validator.ValidationException` if the validation is not successful.
      Returns:
        A `PropertyBox` containing the property values (never null)
      Throws:
        `com.holonplatform.core.Validator.ValidationException` - If `validate` is `true` and an `Input` value is not valid

    - #### getValue

          com.holonplatform.core.property.PropertyBox getValue()

      Get the current property values collected into a `PropertyBox`, using the group configured properties as property set.

      For each property with a bound `Input` component, the property value is obtained from the `Input` component through the `ValueHolder.getValue()` method.

      The group `Input`s and the group value validation is performed before returning the value, throwing a `Validator.ValidationException` if the validation is not successful.

      Specified by:
        `getValue` in interface `ValueHolder<com.holonplatform.core.property.PropertyBox,GroupValueChangeEvent<com.holonplatform.core.property.PropertyBox,com.holonplatform.core.property.Property<?>,Input<?>,PropertyInputGroup>>`
      Returns:
        A `PropertyBox` containing the property values (never null)
      Throws:
        `com.holonplatform.core.Validator.ValidationException` - If one or more input is not valid or the group value is not valid
      See Also:
        `getValue(boolean)`, `getValueIfValid()`

    - #### getValueIfValid

          Optional<com.holonplatform.core.property.PropertyBox> getValueIfValid()

      Get the current property values collected into a `PropertyBox`, using the group configured properties as property set, only if the property bound `Input`s and this `PropertyInputGroup` are valid

      For each property with a bound `Input` component, the property value is obtained from the `Input` component through the `ValueHolder.getValue()` method.

      Returns:
        A `PropertyBox` containing the property values, or an empty Optional if validation failed

    - #### setValue

          void setValue(com.holonplatform.core.property.PropertyBox value,
                        boolean validate)

      Set the current property values using a `PropertyBox`, loading the values to the available property bound `Input`s through the `ValueHolder.setValue(Object)` method.

      Only the properties which belong to the group's property set are taken into account.

      Parameters:
        `value` - the `PropertyBox` which contains the property values to load. If `null`, all the `Input` components are cleared.
        `validate` - `true` to check the validity of the property bound `Input`s and of this `PropertyInputGroup`, throwing a `Validator.ValidationException` if the validation is not successful.
      Throws:
        `com.holonplatform.core.Validator.ValidationException` - If `validate` is `true` and validation fails

    - #### setValue

          void setValue(com.holonplatform.core.property.PropertyBox value)

      Set the current property values using a `PropertyBox`, loading the values to the available property bound `Input`s through the `ValueHolder.setValue(Object)` method.

      Only the properties which belong to the group's property set are taken into account.

      By default, no value validation is performed using this method.

      Specified by:
        `setValue` in interface `ValueHolder<com.holonplatform.core.property.PropertyBox,GroupValueChangeEvent<com.holonplatform.core.property.PropertyBox,com.holonplatform.core.property.Property<?>,Input<?>,PropertyInputGroup>>`
      Parameters:
        `value` - the `PropertyBox` which contains the property values to load. If `null`, all the `Input` components are cleared.
      See Also:
        `setValue(PropertyBox, boolean)`

    - #### setReadOnly

          void setReadOnly(boolean readOnly)

      Set the read-only mode for all the group inputs.
      Parameters:
        `readOnly` - `true` to set all inputs as read-only, `false` to unset

    - #### setEnabled

          void setEnabled(boolean enabled)

      Updates the enabled state of all the group inputs.
      Parameters:
        `enabled` - `true` to enable all group inputs, `false` to disable them

    - #### validate

          void validate()
                 throws com.holonplatform.core.Validator.ValidationException

      Checks the validity of each input component of the group and of the group value against every registered validator, if any.
      Specified by:
        `validate` in interface `Validatable`
      Throws:
        `com.holonplatform.core.Validator.ValidationException` - If validation fails

    - #### builder

          static <P extends com.holonplatform.core.property.Property> PropertyInputGroupBuilder builder(Iterable<P> properties)

      Get a `PropertyInputGroupBuilder` to create and setup a `PropertyInputGroup`.
      Type Parameters:
        `P` - Property type
      Parameters:
        `properties` - The property set (not null)
      Returns:
        A new `PropertyInputGroupBuilder`

    - #### builder

          static PropertyInputGroupBuilder builder(com.holonplatform.core.property.Property<?>... properties)

      Get a `PropertyInputGroupBuilder` to create and setup a `PropertyInputGroup`.
      Parameters:
        `properties` - The property set (not null)
      Returns:
        A new `PropertyInputGroupBuilder`

Copyright © 2019 The Holon Platform. All rights reserved.