Class FileUploadField

java.lang.Object
com.vaadin.flow.component.Component
com.vaadin.flow.component.AbstractField<C,V>
All Implemented Interfaces:
com.vaadin.flow.component.AttachNotifier, com.vaadin.flow.component.DetachNotifier, com.vaadin.flow.component.HasElement, com.vaadin.flow.component.HasEnabled, com.vaadin.flow.component.HasHelper, com.vaadin.flow.component.HasLabel, com.vaadin.flow.component.HasSize, com.vaadin.flow.component.HasStyle, com.vaadin.flow.component.HasTheme, com.vaadin.flow.component.HasValidation, com.vaadin.flow.component.HasValue<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<FileUploadField,byte[]>,byte[]>, com.vaadin.flow.component.HasValueAndElement<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<FileUploadField,byte[]>,byte[]>, com.vaadin.flow.component.shared.HasTooltip, com.vaadin.flow.component.shared.HasValidationProperties, HasRequired, SupportsStatusChangeHandler<FileUploadField>, SupportsValidation<byte[]>, SupportsValueSource<byte[]>, Serializable, org.springframework.beans.factory.Aware, org.springframework.beans.factory.InitializingBean, org.springframework.context.ApplicationContextAware

public class FileUploadField extends JmixFileUploadField<FileUploadField> implements SupportsValueSource<byte[]>, SupportsValidation<byte[]>, SupportsStatusChangeHandler<FileUploadField>, HasRequired, org.springframework.context.ApplicationContextAware, org.springframework.beans.factory.InitializingBean
See Also:
  • Field Details

    • applicationContext

      protected org.springframework.context.ApplicationContext applicationContext
    • messages

      protected Messages messages
    • downloader

      protected Downloader downloader
    • notifications

      protected Notifications notifications
    • multipartPropertiesProvider

      protected org.springframework.beans.factory.ObjectProvider<org.springframework.boot.autoconfigure.web.servlet.MultipartProperties> multipartPropertiesProvider
    • fieldDelegate

      protected FileFieldDelegate<FileUploadField,byte[],byte[]> fieldDelegate
  • Constructor Details

    • FileUploadField

      public FileUploadField()
  • Method Details

    • setApplicationContext

      public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext) throws org.springframework.beans.BeansException
      Specified by:
      setApplicationContext in interface org.springframework.context.ApplicationContextAware
      Throws:
      org.springframework.beans.BeansException
    • afterPropertiesSet

      public void afterPropertiesSet() throws Exception
      Specified by:
      afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
      Throws:
      Exception
    • autowireDependencies

      protected void autowireDependencies()
    • initComponent

      protected void initComponent()
    • createFieldDelegate

      protected FileFieldDelegate<FileUploadField,byte[],byte[]> createFieldDelegate()
    • getValueSource

      @Nullable public ValueSource<byte[]> getValueSource()
      Description copied from interface: SupportsValueSource
      Returns the current ValueSource associated with this component.
      Specified by:
      getValueSource in interface SupportsValueSource<byte[]>
      Returns:
      the associated ValueSource, or null if no value source is set
    • setValueSource

      public void setValueSource(@Nullable ValueSource<byte[]> valueSource)
      Description copied from interface: SupportsValueSource
      Sets a ValueSource for this component, allowing it to bind its value to a specified data source.
      Specified by:
      setValueSource in interface SupportsValueSource<byte[]>
      Parameters:
      valueSource - the ValueSource to be associated with this component, or null to remove the current association
    • isInvalid

      public boolean isInvalid()
      Specified by:
      isInvalid in interface com.vaadin.flow.component.HasValidation
      Specified by:
      isInvalid in interface com.vaadin.flow.component.shared.HasValidationProperties
    • validate

      protected void validate()
    • setRequired

      public void setRequired(boolean required)
      Description copied from interface: HasRequired
      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.
      Specified by:
      setRequired in interface HasRequired
      Parameters:
      required - a boolean value indicating whether the component is marked as required. true to mark the component as required, false otherwise.
    • setRequiredIndicatorVisible

      public void setRequiredIndicatorVisible(boolean requiredIndicatorVisible)
      Specified by:
      setRequiredIndicatorVisible in interface com.vaadin.flow.component.HasValue<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<FileUploadField,byte[]>,byte[]>
      Specified by:
      setRequiredIndicatorVisible in interface com.vaadin.flow.component.HasValueAndElement<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<FileUploadField,byte[]>,byte[]>
    • getRequiredMessage

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

      public void setRequiredMessage(@Nullable String requiredMessage)
      Description copied from interface: HasRequired
      Sets a message that will be displayed or logged when a required field or input is not provided.
      Specified by:
      setRequiredMessage in interface HasRequired
      Parameters:
      requiredMessage - the message to be set for required fields. If null, the default message or no message will be used.
    • addValidator

      public com.vaadin.flow.shared.Registration addValidator(Validator<? super byte[]> validator)
      Description copied from interface: SupportsValidation
      Adds a validator to the list of validators for the component. The provided validator will be used to validate the value of the component during validation execution.
      Specified by:
      addValidator in interface SupportsValidation<byte[]>
      Parameters:
      validator - the validator to be added; should not be null
      Returns:
      a Registration object that allows removing the added validator
    • executeValidators

      public void executeValidators() throws ValidationException
      Description copied from interface: SupportsValidation
      Executes all registered validators against the current value of the component. If any of the validators fail, a ValidationException is thrown to indicate the failure. The exact behavior and order of validation depend on the validators added.
      Specified by:
      executeValidators in interface SupportsValidation<byte[]>
      Throws:
      ValidationException - if validation fails for one or more validators
    • setInvalid

      public void setInvalid(boolean invalid)
      Description copied from interface: SupportsValidation
      Sets invalid state to the field considering result of field validation.
      • Invalid - false and validation passed - false = field is invalid
      • Invalid - false and validation passed - true = field is valid
      • Invalid - true and validation passed - false = field is invalid
      • Invalid - true and validation passed - true = field is invalid
      Specified by:
      setInvalid in interface com.vaadin.flow.component.HasValidation
      Specified by:
      setInvalid in interface com.vaadin.flow.component.shared.HasValidationProperties
      Specified by:
      setInvalid in interface SupportsValidation<byte[]>
      Parameters:
      invalid - whether field should be invalid
    • setReadOnly

      public void setReadOnly(boolean readOnly)
      Specified by:
      setReadOnly in interface com.vaadin.flow.component.HasValue<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<FileUploadField,byte[]>,byte[]>
      Specified by:
      setReadOnly in interface com.vaadin.flow.component.HasValueAndElement<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<FileUploadField,byte[]>,byte[]>
      Overrides:
      setReadOnly in class AbstractSingleUploadField<FileUploadField,byte[]>
    • setEnabled

      public void setEnabled(boolean enabled)
      Specified by:
      setEnabled in interface com.vaadin.flow.component.HasEnabled
      Overrides:
      setEnabled in class AbstractSingleUploadField<FileUploadField,byte[]>
    • setStatusChangeHandler

      public void setStatusChangeHandler(@Nullable Consumer<SupportsStatusChangeHandler.StatusContext<FileUploadField>> handler)
      Description copied from interface: SupportsStatusChangeHandler
      Sets a callback to be used to handle component status changes, e.g. validation messages set by HasValidation.setErrorMessage(String).
      Specified by:
      setStatusChangeHandler in interface SupportsStatusChangeHandler<FileUploadField>
      Parameters:
      handler - a handler to set
    • setMaxFileSize

      public void setMaxFileSize(int maxFileSize)
      Specify the maximum file size in bytes allowed to upload. Notice that it is a client-side constraint, which will be checked before sending the request.

      Note if MultipartProperties is available, the default value will be set from MultipartProperties.getMaxFileSize() that is equal to 1Mb. To increase maximum file size for all fields in the application use MultipartProperties.getMaxFileSize() property.

      Overrides:
      setMaxFileSize in class AbstractSingleUploadField<FileUploadField,byte[]>
      Parameters:
      maxFileSize - the maximum file size in bytes
      See Also:
      • Upload.setMaxFileSize(int)
      • MultipartProperties.getMaxFileSize()
      • MultipartProperties.getMaxRequestSize()
    • onFileNameClick

      protected void onFileNameClick(com.vaadin.flow.component.ClickEvent<?> clickEvent)
    • handleJmixUploadInternalError

      protected void handleJmixUploadInternalError(String fileName)
      Overrides:
      handleJmixUploadInternalError in class AbstractSingleUploadField<FileUploadField,byte[]>
    • showUploadErrorNotification

      protected void showUploadErrorNotification(String fileName)
    • generateFileName

      protected String generateFileName()
      Overrides:
      generateFileName in class JmixFileUploadField<FileUploadField>
    • getDefaultUploadText

      protected String getDefaultUploadText()
      Overrides:
      getDefaultUploadText in class JmixFileUploadField<FileUploadField>
    • convertValueToFileName

      protected String convertValueToFileName(byte[] value)
      Overrides:
      convertValueToFileName in class JmixFileUploadField<FileUploadField>
    • attachValueChangeListener

      protected void attachValueChangeListener(com.vaadin.flow.component.HasValue.ValueChangeListener<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<FileUploadField,byte[]>> listener)
    • onValueChange

      protected void onValueChange(com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<FileUploadField,byte[]> event)
    • onFileRejectedEvent

      protected void onFileRejectedEvent(com.vaadin.flow.component.upload.FileRejectedEvent event)
      Overrides:
      onFileRejectedEvent in class AbstractSingleUploadField<FileUploadField,byte[]>
    • applyI18nDefaults

      protected void applyI18nDefaults()