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,Serializable
public class JmixFileDownloader
extends com.vaadin.flow.component.Composite<com.vaadin.flow.component.html.Anchor>
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic class -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final Stringprotected Stringprotected com.vaadin.flow.function.SerializableConsumer<OutputStream>protected Stringprotected Predicate<JmixFileDownloader.FileNotFoundContext>protected booleanprotected com.vaadin.flow.server.RequestHandlerprotected static final String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidcom.vaadin.flow.shared.RegistrationaddDownloadFinishedListener(com.vaadin.flow.component.ComponentEventListener<JmixFileDownloader.DownloadFinishedEvent> listener) Adds a listener that is executed when the file content has been streamed.protected voidafterWriteHandler(OutputStream outputStream) protected voidbeforeClientResponseDownloadHandler(com.vaadin.flow.component.UI ui) voiddownloadFile(com.vaadin.flow.server.StreamResource resource) protected voidexecute()getFileName(com.vaadin.flow.server.VaadinSession session, com.vaadin.flow.server.VaadinRequest request) Gets the filename of downloaded file.protected voidonDetach(com.vaadin.flow.component.DetachEvent detachEvent) protected voidrunBeforeClientResponse(com.vaadin.flow.function.SerializableConsumer<com.vaadin.flow.component.UI> command) protected voidrunCommand(com.vaadin.flow.server.StreamResource resource) voidsetFileName(String fileName) voidsetFileNotFoundExceptionHandler(Predicate<JmixFileDownloader.FileNotFoundContext> fileNotFoundExceptionHandler) voidviewDocument(com.vaadin.flow.server.StreamResource resource) Methods inherited from class com.vaadin.flow.component.Composite
getChildren, getContent, getElement, initContentMethods 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, scrollIntoView, set, setElement, setId, setVisibleMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.vaadin.flow.component.AttachNotifier
addAttachListenerMethods inherited from interface com.vaadin.flow.component.DetachNotifier
addDetachListener
-
Field Details
-
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 @Pushin use or useUI.setPollInterval(int)method.- Parameters:
listener- the listener- Returns:
- the
Registrationyou 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:
onDetachin 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()
-