Interface HasRequired

All Superinterfaces:
com.vaadin.flow.component.HasElement, Serializable
All Known Implementing Classes:
CodeEditor, EntityComboBox, EntityPicker, FileStorageUploadField, FileUploadField, FullTextFilter, JmixBigDecimalField, JmixCheckbox, JmixCheckboxGroup, JmixComboBox, JmixEmailField, JmixIntegerField, JmixMultiSelectComboBox, JmixMultiSelectComboBoxPicker, JmixMultiValuePicker, JmixNumberField, JmixPasswordField, JmixRadioButtonGroup, JmixSelect, JmixTextArea, JmixValuePicker, JpqlFilter, PropertyFilter, SingleFilterComponentBase, Switch, TwinColumn, TypedDatePicker, TypedDateTimePicker, TypedTextField, TypedTimePicker, WebdavDocumentUploadField

public interface HasRequired extends com.vaadin.flow.component.HasElement
Interface that defines behavior for components that can be marked as required. Provides methods to handle the required state and required messages for validation purposes.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
     
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the custom validation message to be displayed if the component is marked as required and the validation fails due to a missing value.
    default boolean
    Determines if the component is marked as required.
    default void
    setRequired(boolean required)
    Sets the required property for the component.
    void
    setRequiredMessage(String requiredMessage)
    Sets a message that will be displayed or logged when a required field or input is not provided.

    Methods inherited from interface com.vaadin.flow.component.HasElement

    getElement
  • Field Details

  • Method Details

    • isRequired

      default boolean isRequired()
      Determines if the component is marked as required.
      Returns:
      true if the component is required, false otherwise
    • setRequired

      default void setRequired(boolean required)
      Sets the required property for the component. When a component is marked as required, it indicates that a value must be provided for the component in order to pass validation.
      Parameters:
      required - a boolean value indicating whether the component is marked as required. true to mark the component as required, false otherwise.
    • getRequiredMessage

      @Nullable String getRequiredMessage()
      Returns the custom validation message to be displayed if the component is marked as required and the validation fails due to a missing value.
      Returns:
      the required message set for the component, or null if no message is defined
    • setRequiredMessage

      void setRequiredMessage(@Nullable String requiredMessage)
      Sets a message that will be displayed or logged when a required field or input is not provided.
      Parameters:
      requiredMessage - the message to be set for required fields. If null, the default message or no message will be used.