Class JmixFileDownloader
java.lang.Object
com.vaadin.flow.component.Component
com.vaadin.flow.component.Composite<com.vaadin.flow.component.html.Anchor>
io.jmix.flowui.component.filedownloader.JmixFileDownloader
- All Implemented Interfaces:
com.vaadin.flow.component.AttachNotifier
,com.vaadin.flow.component.DetachNotifier
,com.vaadin.flow.component.HasElement
,com.vaadin.flow.component.HasStyle
,Serializable
public class JmixFileDownloader
extends com.vaadin.flow.component.Composite<com.vaadin.flow.component.html.Anchor>
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
static class
-
Field Summary
Modifier and TypeFieldDescriptionprotected static final String
protected String
protected com.vaadin.flow.function.SerializableConsumer<OutputStream>
protected static final String
protected String
protected Predicate<JmixFileDownloader.FileNotFoundContext>
protected boolean
protected com.vaadin.flow.server.RequestHandler
protected static final String
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
com.vaadin.flow.shared.Registration
addDownloadFinishedListener
(com.vaadin.flow.component.ComponentEventListener<JmixFileDownloader.DownloadFinishedEvent> listener) Adds a listener that is executed when the file content has been streamed.protected void
afterWriteHandler
(OutputStream outputStream) protected void
beforeClientResponseDownloadHandler
(com.vaadin.flow.component.UI ui) void
downloadFile
(com.vaadin.flow.server.StreamResource resource) protected void
execute()
getFileName
(com.vaadin.flow.server.VaadinSession session, com.vaadin.flow.server.VaadinRequest request) Gets the filename of downloaded file.protected void
onDetach
(com.vaadin.flow.component.DetachEvent detachEvent) protected void
runBeforeClientResponse
(com.vaadin.flow.function.SerializableConsumer<com.vaadin.flow.component.UI> command) protected void
runCommand
(com.vaadin.flow.server.StreamResource resource) void
setFileName
(String fileName) void
setFileNotFoundExceptionHandler
(Predicate<JmixFileDownloader.FileNotFoundContext> fileNotFoundExceptionHandler) void
viewDocument
(com.vaadin.flow.server.StreamResource resource) Methods inherited from class com.vaadin.flow.component.Composite
getChildren, getContent, getElement, initContent
Methods inherited from class com.vaadin.flow.component.Component
addListener, findAncestor, fireEvent, from, get, getEventBus, getId, getListeners, getLocale, getParent, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onAttach, 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.HasStyle
addClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassName
-
Field Details
-
DOWNLOAD_RESOURCE_PREFIX
- See Also:
-
CLICK_EXPRESSION
- See Also:
-
SELF_REMOVE_EXPRESSION
- See Also:
-
fileName
-
requestHandler
protected com.vaadin.flow.server.RequestHandler requestHandler -
contentWriter
-
isViewDocumentRequest
protected boolean isViewDocumentRequest -
contentType
-
fileNotFoundExceptionHandler
-
-
Constructor Details
-
JmixFileDownloader
public JmixFileDownloader()
-
-
Method Details
-
setFileName
-
getFileName
public String getFileName(com.vaadin.flow.server.VaadinSession session, com.vaadin.flow.server.VaadinRequest request) Gets the filename of downloaded file. Override if you want to generate the name dynamically.- Parameters:
session
- the vaadin sessionrequest
- the vaadin request- Returns:
- the file name
-
setFileNotFoundExceptionHandler
public void setFileNotFoundExceptionHandler(Predicate<JmixFileDownloader.FileNotFoundContext> fileNotFoundExceptionHandler) -
getFileNotFoundExceptionHandler
-
addDownloadFinishedListener
public com.vaadin.flow.shared.Registration addDownloadFinishedListener(com.vaadin.flow.component.ComponentEventListener<JmixFileDownloader.DownloadFinishedEvent> listener) Adds a listener that is executed when the file content has been streamed. Note that the UI changes done in the listener don't necessarily happen live if you don't have @Push
in use or useUI.setPollInterval(int)
method.- Parameters:
listener
- the listener- Returns:
- the
Registration
you can use to remove this listener.
-
downloadFile
public void downloadFile(com.vaadin.flow.server.StreamResource resource) -
viewDocument
public void viewDocument(com.vaadin.flow.server.StreamResource resource) -
runCommand
protected void runCommand(com.vaadin.flow.server.StreamResource resource) -
execute
protected void execute() -
beforeClientResponseDownloadHandler
protected void beforeClientResponseDownloadHandler(com.vaadin.flow.component.UI ui) -
onDetach
protected void onDetach(com.vaadin.flow.component.DetachEvent detachEvent) - Overrides:
onDetach
in classcom.vaadin.flow.component.Component
-
afterWriteHandler
-
runBeforeClientResponse
protected void runBeforeClientResponse(com.vaadin.flow.function.SerializableConsumer<com.vaadin.flow.component.UI> command) -
accessCommand
protected void accessCommand()
-