Class DynamicFileDownloader

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  DynamicFileDownloader.DownloadFinishedEvent  
      • Nested classes/interfaces inherited from interface com.vaadin.flow.component.BlurNotifier

        com.vaadin.flow.component.BlurNotifier.BlurEvent<C extends com.vaadin.flow.component.Component>
      • Nested classes/interfaces inherited from interface com.vaadin.flow.component.FocusNotifier

        com.vaadin.flow.component.FocusNotifier.FocusEvent<C extends com.vaadin.flow.component.Component>
      • Nested classes/interfaces inherited from interface com.vaadin.flow.component.HasText

        com.vaadin.flow.component.HasText.WhiteSpace
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected com.vaadin.flow.server.RequestHandler requestHandler  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      com.vaadin.flow.shared.Registration addDownloadFinishedListener​(com.vaadin.flow.component.ComponentEventListener<DynamicFileDownloader.DownloadFinishedEvent> listener)
      Adds a listener that is executed when the file content has been streamed.
      DynamicFileDownloader asButton()
      Makes the download look like a button instead of a normal link.
      com.vaadin.flow.component.button.Button getButton()  
      protected String 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)  
      void setDisableOnClick​(boolean disableOnClick)  
      void setFileHandler​(com.vaadin.flow.function.SerializableConsumer<OutputStream> contentWriter)  
      void setFileName​(String fileName)  
      • Methods inherited from class com.vaadin.flow.component.html.Anchor

        getHref, getTarget, getTargetValue, onEnabledStateChanged, removeHref, setHref, setHref, setTarget, setTarget
      • Methods inherited from class com.vaadin.flow.component.HtmlComponent

        getTitle, setTitle
      • Methods inherited from class com.vaadin.flow.component.Component

        addListener, fireEvent, from, get, getChildren, getElement, getEventBus, getId, getLocale, getParent, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onAttach, set, setElement, setId, setVisible
      • Methods inherited from interface com.vaadin.flow.component.AttachNotifier

        addAttachListener
      • Methods inherited from interface com.vaadin.flow.component.BlurNotifier

        addBlurListener
      • Methods inherited from interface com.vaadin.flow.component.DetachNotifier

        addDetachListener
      • Methods inherited from interface com.vaadin.flow.component.Focusable

        addFocusShortcut, blur, focus, getTabIndex, setTabIndex
      • Methods inherited from interface com.vaadin.flow.component.FocusNotifier

        addFocusListener
      • Methods inherited from interface com.vaadin.flow.component.HasAriaLabel

        getAriaLabel, setAriaLabel
      • Methods inherited from interface com.vaadin.flow.component.HasComponents

        add, add, addComponentAsFirst, addComponentAtIndex, remove, removeAll
      • Methods inherited from interface com.vaadin.flow.component.HasElement

        getElement
      • Methods inherited from interface com.vaadin.flow.component.HasEnabled

        isEnabled, setEnabled
      • 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.HasText

        getText, getWhiteSpace, setText, setWhiteSpace
    • Field Detail

      • requestHandler

        protected com.vaadin.flow.server.RequestHandler requestHandler
    • Constructor Detail

      • DynamicFileDownloader

        public DynamicFileDownloader​(String text,
                                     String fileName,
                                     com.vaadin.flow.function.SerializableConsumer<OutputStream> contentWriter)
      • DynamicFileDownloader

        public DynamicFileDownloader()
    • Method Detail

      • setDisableOnClick

        public void setDisableOnClick​(boolean disableOnClick)
      • onDetach

        protected void onDetach​(com.vaadin.flow.component.DetachEvent detachEvent)
        Overrides:
        onDetach in class com.vaadin.flow.component.Component
      • addDownloadFinishedListener

        public com.vaadin.flow.shared.Registration addDownloadFinishedListener​(com.vaadin.flow.component.ComponentEventListener<DynamicFileDownloader.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.
      • setFileHandler

        public void setFileHandler​(com.vaadin.flow.function.SerializableConsumer<OutputStream> contentWriter)
      • setFileName

        public void setFileName​(String fileName)
      • getFileName

        protected 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
      • asButton

        public DynamicFileDownloader asButton()
        Makes the download look like a button instead of a normal link.
        Returns:
        the same instance, fluent method
      • getButton

        public com.vaadin.flow.component.button.Button getButton()
        Returns:
        a Button component wrapped inside the file downloader, if configured as a Button