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:
  • Field Details

    • CLICK_EXPRESSION

      protected static final String CLICK_EXPRESSION
      See Also:
    • SELF_REMOVE_EXPRESSION

      protected static final String SELF_REMOVE_EXPRESSION
      See Also:
    • fileName

      protected String fileName
    • requestHandler

      protected com.vaadin.flow.server.RequestHandler requestHandler
    • contentWriter

      protected com.vaadin.flow.function.SerializableConsumer<OutputStream> contentWriter
    • isViewDocumentRequest

      protected boolean isViewDocumentRequest
    • contentType

      protected String contentType
    • fileNotFoundExceptionHandler

      protected Predicate<JmixFileDownloader.FileNotFoundContext> fileNotFoundExceptionHandler
  • Constructor Details

    • JmixFileDownloader

      public JmixFileDownloader()
  • Method Details

    • setFileName

      public void setFileName(String fileName)
    • 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 session
      request - the vaadin request
      Returns:
      the file name
    • setFileNotFoundExceptionHandler

      public void setFileNotFoundExceptionHandler(Predicate<JmixFileDownloader.FileNotFoundContext> fileNotFoundExceptionHandler)
    • getFileNotFoundExceptionHandler

      public Predicate<JmixFileDownloader.FileNotFoundContext> 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 use UI.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 class com.vaadin.flow.component.Component
    • afterWriteHandler

      protected void afterWriteHandler(OutputStream outputStream)
    • runBeforeClientResponse

      protected void runBeforeClientResponse(com.vaadin.flow.function.SerializableConsumer<com.vaadin.flow.component.UI> command)
    • accessCommand

      protected void accessCommand()