Class CustomField<T>

    • Constructor Detail

      • CustomField

        public CustomField()
        Default constructor.
    • Method Detail

      • onAttach

        protected void onAttach​(AttachEvent attachEvent)
        Description copied from class: Component
        Called when the component is attached to a UI.

        The default implementation does nothing.

        This method is invoked before the AttachEvent is fired for the component.

        Overrides:
        onAttach in class Component
        Parameters:
        attachEvent - the attach event
      • generateModelValue

        protected abstract T generateModelValue()
        This method should return the value of the field, based on value of the internal fields.
        Returns:
        new value of the field.
      • setPresentationValue

        protected abstract void setPresentationValue​(T newPresentationValue)
        This method should be implemented to set the value of the fields contained in this custom field according to the value of the parameter. It can also be use to show the value to the user in some way, like placing it in an element contained on the field.

        Updates the presentation of this field to display the provided value. Subclasses should override this method to show the value to the user. This is typically done by setting an element property or by applying changes to child components.

        If AbstractField.setModelValue(Object, boolean) is called from within this method, the value of the last invocation will be used as the model value instead of the value passed to this method. In this case AbstractField.setPresentationValue(Object) will not be called again. Changing the provided value might be useful if the provided value is sanitized.

        See AbstractField for an overall description on the difference between model values and presentation values.

        Specified by:
        setPresentationValue in class AbstractField<CustomField<T>,​T>
        Parameters:
        newPresentationValue - The new presentation value.
      • add

        protected void add​(Component... components)
        Adds the given components as children of this component.
        Parameters:
        components - the components to add
      • remove

        protected void remove​(Component... components)
        Removes the given child components from this component.
        Parameters:
        components - the components to remove
        Throws:
        IllegalArgumentException - if any of the components is not a child of this component
      • isInvalid

        public boolean isInvalid()

        This property is set to true when the control value is invalid.

        Specified by:
        isInvalid in interface HasValidation
        Returns:
        the invalid property from the webcomponent
      • setInvalid

        public void setInvalid​(boolean invalid)

        This property is set to true when the control value is invalid.

        Specified by:
        setInvalid in interface HasValidation
        Parameters:
        invalid - the boolean value to set
      • setErrorMessage

        public void setErrorMessage​(String errorMessage)
        Description copied from interface: HasValidation
        Sets an error message to the component.

        The Web Component is responsible for deciding when to show the error message to the user, and this is usually triggered by triggering the invalid state for the Web Component. Which means that there is no need to clean up the message when component becomes valid (otherwise it may lead to undesired visual effects).

        Specified by:
        setErrorMessage in interface HasValidation
        Parameters:
        errorMessage - a new error message
      • getErrorMessage

        public String getErrorMessage()
        Description copied from interface: HasValidation
        Gets current error message from the component.
        Specified by:
        getErrorMessage in interface HasValidation
        Returns:
        current error message
      • getLabel

        public String getLabel()
        Gets the label for the field.
        Specified by:
        getLabel in interface HasLabel
        Returns:
        the label property from the webcomponent
      • setLabel

        public void setLabel​(String label)
        Sets the label for the field.
        Specified by:
        setLabel in interface HasLabel
        Parameters:
        label - value for the label property in the webcomponent
      • addThemeVariants

        public void addThemeVariants​(CustomFieldVariant... variants)
        Adds theme variants to the component.
        Parameters:
        variants - theme variants to add
      • removeThemeVariants

        public void removeThemeVariants​(CustomFieldVariant... variants)
        Removes theme variants from the component.
        Parameters:
        variants - theme variants to remove