Class DiscriminatorControl

  • All Implemented Interfaces:
    Serializable

    public final class DiscriminatorControl
    extends EditableControl<Object>
    A Control for selecting the discriminator of a union value. The discriminator is used to select the value descriptor to apply to the value. Rendered as a dropdown/select box.
    Since:
    8.5.0
    See Also:
    Serialized Form
    • Constructor Detail

      • DiscriminatorControl

        public DiscriminatorControl​(IValueAccessor<?> root,
                                    String path,
                                    IUnionValueDescriptor descriptor)
        Creates a new discriminator control.
        Parameters:
        root - The root object containing the value.
        path - The path to the value within the root object.
        descriptor - The union value descriptor describing the possible union members.
    • Method Detail

      • getCurrentDiscriminator

        public int getCurrentDiscriminator()
        Gets the currently selected discriminator.
        Returns:
        The currently selected discriminator.
      • setCurrentDiscriminator

        public void setCurrentDiscriminator​(int discriminator)
        Sets the currently selected discriminator. This WILL NOT update the value of the control to conform to the descriptor of the new discriminator. Call updateDiscriminator() to do so.
        Parameters:
        discriminator - The discriminator to select.
      • getOptions

        public List<javax.faces.model.SelectItem> getOptions()
        Gets the options for the discriminator select box.
        Returns:
        The options for the discriminator select box.
      • updateDiscriminator

        public void updateDiscriminator()
        Updates the value so that it conforms to the currently selected discriminator. If the current value does not conform to the selected discriminator, it will be replaced with a new value that does. If the discriminator has not changed, this method does nothing.

        Usually this method should be called during the invoke application phase of the Faces lifecycle; after the apply request values phase has completed and updated the current discriminator.

      • coerceValue

        protected Object coerceValue​(Object value)
        Coerces the value to conform to the currently selected discriminator.
        Specified by:
        coerceValue in class EditableControl<Object>
        Parameters:
        value - The value to coerce.
        Returns:
        The coerced value, or null if the current discriminator is invalid.