Package io.jmix.flowui.component.upload
Class FileUploadField
java.lang.Object
com.vaadin.flow.component.Component
com.vaadin.flow.component.AbstractField<C,V>
io.jmix.flowui.kit.component.upload.AbstractSingleUploadField<C,byte[]>
io.jmix.flowui.kit.component.upload.JmixFileUploadField<FileUploadField>
io.jmix.flowui.component.upload.FileUploadField
- 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:
-
Nested Class Summary
Nested classes/interfaces inherited from class com.vaadin.flow.component.AbstractField
com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<C extends com.vaadin.flow.component.Component,
V extends Object> Nested classes/interfaces inherited from interface com.vaadin.flow.component.HasValue
com.vaadin.flow.component.HasValue.ValueChangeEvent<V extends Object>, com.vaadin.flow.component.HasValue.ValueChangeListener<E extends com.vaadin.flow.component.HasValue.ValueChangeEvent<?>>
Nested classes/interfaces inherited from interface io.jmix.flowui.component.SupportsStatusChangeHandler
SupportsStatusChangeHandler.StatusContext<C extends com.vaadin.flow.component.Component>
-
Field Summary
Modifier and TypeFieldDescriptionprotected org.springframework.context.ApplicationContext
protected Downloader
protected FileFieldDelegate<FileUploadField,
byte[], byte[]> protected Messages
protected org.springframework.beans.factory.ObjectProvider<org.springframework.boot.autoconfigure.web.servlet.MultipartProperties>
protected Notifications
Fields inherited from class io.jmix.flowui.kit.component.upload.JmixFileUploadField
fileName, uploadedFileName
Fields inherited from class io.jmix.flowui.kit.component.upload.AbstractSingleUploadField
CLEAR_COMPONENT_ARIA_LABEL, CLEAR_COMPONENT_CLASS_NAME, clearButtonVisible, clearComponent, content, FILE_NAME_COMPONENT_CLASS_NAME, FILE_NAME_COMPONENT_EMPTY_CLASS_NAME, FILE_NOT_SELECTED, fileNameComponent, fileNameVisible, fileNotSelectedText, FULL_WIDTH_THEME, INPUT_CONTAINER_CLASS_NAME, internalValue, NO_FILE_NAME_THEME, UPLOAD, uploadButton, uploadText
Fields inherited from interface io.jmix.flowui.component.HasRequired
PROPERTY_REQUIRED
Fields inherited from interface io.jmix.flowui.component.SupportsValidation
PROPERTY_ERROR_MESSAGE
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptioncom.vaadin.flow.shared.Registration
addValidator
(Validator<? super byte[]> validator) void
protected void
protected void
attachValueChangeListener
(com.vaadin.flow.component.HasValue.ValueChangeListener<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<FileUploadField, byte[]>> listener) protected void
protected String
convertValueToFileName
(byte[] value) protected FileFieldDelegate<FileUploadField,
byte[], byte[]> void
protected String
protected String
ValueSource<byte[]>
protected void
handleJmixUploadInternalError
(String fileName) protected void
boolean
protected void
onFileNameClick
(com.vaadin.flow.component.ClickEvent<?> clickEvent) protected void
onFileRejectedEvent
(com.vaadin.flow.component.upload.FileRejectedEvent event) protected void
onValueChange
(com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<FileUploadField, byte[]> event) void
setApplicationContext
(org.springframework.context.ApplicationContext applicationContext) void
setEnabled
(boolean enabled) void
setInvalid
(boolean invalid) Sets invalid state to the field considering result of field validation.void
setMaxFileSize
(int maxFileSize) Specify the maximum file size in bytes allowed to upload.void
setReadOnly
(boolean readOnly) void
setRequired
(boolean required) void
setRequiredIndicatorVisible
(boolean requiredIndicatorVisible) void
setRequiredMessage
(String requiredMessage) void
setStatusChangeHandler
(Consumer<SupportsStatusChangeHandler.StatusContext<FileUploadField>> handler) Sets a callback to be used to handle component status changes, e.g.void
setValueSource
(ValueSource<byte[]> valueSource) protected void
showUploadErrorNotification
(String fileName) protected void
validate()
Methods inherited from class io.jmix.flowui.kit.component.upload.JmixFileUploadField
getFileName, getUploadedFileName, onSucceededEvent, saveFile, setFileName, setInternalValue, valueEquals
Methods inherited from class io.jmix.flowui.kit.component.upload.AbstractSingleUploadField
addClassNames, addFileUploadFailedListener, addFileUploadFileRejectedListener, addFileUploadFinishedListener, addFileUploadProgressListener, addFileUploadStartedListener, addFileUploadSucceededListener, addThemeNames, addValueChangeListener, attachContent, attachUploadEvents, createClearComponent, createContentComponent, createFileNameComponent, createUploadButtonComponent, createUploadComponent, createUploadReceiver, getAcceptedFileTypes, getClearButtonAriaLabel, getContent, getEmptyValue, getFileNotSelectedText, getI18n, getMaxFileSize, getUploadIcon, getUploadText, getValue, initClearComponent, initContentComponent, initFileNameComponent, initUploadButtonComponent, initUploadComponent, isClearButtonVisible, isDropAllowed, isFileNameVisible, onClearButtonClick, onFailedEvent, onFinishedEvent, onJmixUploadInternalError, onProgressEvent, onStartedEvent, removeClassNames, removeThemeNames, setAcceptedFileTypes, setClearButtonAriaLabel, setClearButtonVisible, setComponentAriaLabel, setComponentClickListener, setComponentEnabled, setComponentText, setDropAllowed, setFileNameVisible, setFileNotSelectedText, setI18n, setInternalValue, setPresentationValue, setUploadIcon, setUploadText, setValue, updateComponentsVisibility
Methods inherited from class com.vaadin.flow.component.AbstractField
isEmpty, setModelValue
Methods inherited from class com.vaadin.flow.component.Component
addListener, findAncestor, fireEvent, from, get, getChildren, getElement, getEventBus, getId, getListeners, getLocale, getParent, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onAttach, onDetach, onEnabledStateChanged, removeFromParent, scrollIntoView, scrollIntoView, set, setElement, setId, setVisible
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.vaadin.flow.component.AttachNotifier
addAttachListener
Methods inherited from interface com.vaadin.flow.component.DetachNotifier
addDetachListener
Methods inherited from interface com.vaadin.flow.component.HasElement
getElement
Methods inherited from interface com.vaadin.flow.component.HasEnabled
isEnabled
Methods inherited from interface com.vaadin.flow.component.HasHelper
getHelperComponent, getHelperText, setHelperComponent, setHelperText
Methods inherited from interface com.vaadin.flow.component.HasLabel
getLabel, setLabel
Methods inherited from interface io.jmix.flowui.component.HasRequired
isRequired
Methods inherited from interface com.vaadin.flow.component.HasSize
getHeight, getHeightUnit, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getWidth, getWidthUnit, setHeight, setHeight, setHeightFull, setMaxHeight, setMaxHeight, setMaxWidth, setMaxWidth, setMinHeight, setMinHeight, setMinWidth, setMinWidth, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthFull
Methods inherited from interface com.vaadin.flow.component.HasStyle
addClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassName
Methods inherited from interface com.vaadin.flow.component.HasTheme
addThemeName, addThemeNames, getThemeName, getThemeNames, hasThemeName, removeThemeName, removeThemeNames, setThemeName, setThemeName
Methods inherited from interface com.vaadin.flow.component.shared.HasTooltip
getTooltip, setTooltipText
Methods inherited from interface com.vaadin.flow.component.HasValidation
setManualValidation
Methods inherited from interface com.vaadin.flow.component.HasValue
clear, getOptionalValue
Methods inherited from interface com.vaadin.flow.component.HasValueAndElement
isReadOnly, isRequiredIndicatorVisible
Methods inherited from interface io.jmix.flowui.component.SupportsValidation
getErrorMessage, setErrorMessage
-
Field Details
-
applicationContext
protected org.springframework.context.ApplicationContext applicationContext -
messages
-
downloader
-
notifications
-
multipartPropertiesProvider
protected org.springframework.beans.factory.ObjectProvider<org.springframework.boot.autoconfigure.web.servlet.MultipartProperties> multipartPropertiesProvider -
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 interfaceorg.springframework.context.ApplicationContextAware
- Throws:
org.springframework.beans.BeansException
-
afterPropertiesSet
- Specified by:
afterPropertiesSet
in interfaceorg.springframework.beans.factory.InitializingBean
- Throws:
Exception
-
autowireDependencies
protected void autowireDependencies() -
initComponent
protected void initComponent() -
createFieldDelegate
-
getValueSource
- Specified by:
getValueSource
in interfaceSupportsValueSource<byte[]>
-
setValueSource
- Specified by:
setValueSource
in interfaceSupportsValueSource<byte[]>
-
isInvalid
public boolean isInvalid()- Specified by:
isInvalid
in interfacecom.vaadin.flow.component.HasValidation
- Specified by:
isInvalid
in interfacecom.vaadin.flow.component.shared.HasValidationProperties
-
validate
protected void validate() -
setRequired
public void setRequired(boolean required) - Specified by:
setRequired
in interfaceHasRequired
-
setRequiredIndicatorVisible
public void setRequiredIndicatorVisible(boolean requiredIndicatorVisible) - Specified by:
setRequiredIndicatorVisible
in interfacecom.vaadin.flow.component.HasValue<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<FileUploadField,
byte[]>, byte[]> - Specified by:
setRequiredIndicatorVisible
in interfacecom.vaadin.flow.component.HasValueAndElement<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<FileUploadField,
byte[]>, byte[]>
-
getRequiredMessage
- Specified by:
getRequiredMessage
in interfaceHasRequired
-
setRequiredMessage
- Specified by:
setRequiredMessage
in interfaceHasRequired
-
addValidator
- Specified by:
addValidator
in interfaceSupportsValidation<byte[]>
-
executeValidators
- Specified by:
executeValidators
in interfaceSupportsValidation<byte[]>
- Throws:
ValidationException
-
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 interfacecom.vaadin.flow.component.HasValidation
- Specified by:
setInvalid
in interfacecom.vaadin.flow.component.shared.HasValidationProperties
- Specified by:
setInvalid
in interfaceSupportsValidation<byte[]>
- Parameters:
invalid
- whether field should be invalid
-
setReadOnly
public void setReadOnly(boolean readOnly) - Specified by:
setReadOnly
in interfacecom.vaadin.flow.component.HasValue<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<FileUploadField,
byte[]>, byte[]> - Specified by:
setReadOnly
in interfacecom.vaadin.flow.component.HasValueAndElement<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<FileUploadField,
byte[]>, byte[]> - Overrides:
setReadOnly
in classAbstractSingleUploadField<FileUploadField,
byte[]>
-
setEnabled
public void setEnabled(boolean enabled) - Specified by:
setEnabled
in interfacecom.vaadin.flow.component.HasEnabled
- Overrides:
setEnabled
in classAbstractSingleUploadField<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 byHasValidation.setErrorMessage(String)
.- Specified by:
setStatusChangeHandler
in interfaceSupportsStatusChangeHandler<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 fromMultipartProperties.getMaxFileSize()
that is equal to 1Mb. To increase maximum file size for all fields in the application useMultipartProperties.getMaxFileSize()
property.- Overrides:
setMaxFileSize
in classAbstractSingleUploadField<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
- Overrides:
handleJmixUploadInternalError
in classAbstractSingleUploadField<FileUploadField,
byte[]>
-
showUploadErrorNotification
-
generateFileName
- Overrides:
generateFileName
in classJmixFileUploadField<FileUploadField>
-
getDefaultUploadText
- Overrides:
getDefaultUploadText
in classJmixFileUploadField<FileUploadField>
-
convertValueToFileName
- Overrides:
convertValueToFileName
in classJmixFileUploadField<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 classAbstractSingleUploadField<FileUploadField,
byte[]>
-
applyI18nDefaults
protected void applyI18nDefaults()
-