Package org.vaadin.firitin.components
Class DynamicFileDownloader
java.lang.Object
com.vaadin.flow.component.Component
com.vaadin.flow.component.HtmlComponent
com.vaadin.flow.component.HtmlContainer
com.vaadin.flow.component.html.Anchor
org.vaadin.firitin.components.DynamicFileDownloader
- All Implemented Interfaces:
com.vaadin.flow.component.AttachNotifier,com.vaadin.flow.component.BlurNotifier<com.vaadin.flow.component.html.Anchor>,com.vaadin.flow.component.DetachNotifier,com.vaadin.flow.component.Focusable<com.vaadin.flow.component.html.Anchor>,com.vaadin.flow.component.FocusNotifier<com.vaadin.flow.component.html.Anchor>,com.vaadin.flow.component.HasAriaLabel,com.vaadin.flow.component.HasComponents,com.vaadin.flow.component.HasElement,com.vaadin.flow.component.HasEnabled,com.vaadin.flow.component.HasSize,com.vaadin.flow.component.HasStyle,com.vaadin.flow.component.HasText,Serializable,FluentAttachNotifier<DynamicFileDownloader>,FluentComponent<DynamicFileDownloader>,FluentDetachNotifier<DynamicFileDownloader>,FluentHasEnabled<DynamicFileDownloader>
public class DynamicFileDownloader
extends com.vaadin.flow.component.html.Anchor
implements FluentComponent<DynamicFileDownloader>, FluentHasEnabled<DynamicFileDownloader>
An anchor which content is produced dynamically.
- Author:
- mstahv
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic classNested 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 -
Constructor Summary
ConstructorsConstructorDescriptionDynamicFileDownloader(com.vaadin.flow.component.Component downloadComponent, String fileName, com.vaadin.flow.function.SerializableConsumer<OutputStream> contentWriter) DynamicFileDownloader(String text, String fileName, com.vaadin.flow.function.SerializableConsumer<OutputStream> contentWriter) -
Method Summary
Modifier and TypeMethodDescriptioncom.vaadin.flow.shared.RegistrationaddDownloadFailedListener(com.vaadin.flow.component.ComponentEventListener<DynamicFileDownloader.DownlocadFailedEvent> listener) Adds a listener that is executed when the file content streaming has failed due to an exception.com.vaadin.flow.shared.RegistrationaddDownloadFinishedListener(com.vaadin.flow.component.ComponentEventListener<DynamicFileDownloader.DownloadFinishedEvent> listener) Adds a listener that is executed when the file content has been streamed.asButton()Makes the download look like a button instead of a normal link.com.vaadin.flow.component.button.Buttonprotected StringgetFileName(com.vaadin.flow.server.VaadinSession session, com.vaadin.flow.server.VaadinRequest request) Gets the filename of downloaded file.protected voidonAttach(com.vaadin.flow.component.AttachEvent attachEvent) protected voidonDetach(com.vaadin.flow.component.DetachEvent detachEvent) voidsetDisableOnClick(boolean disableOnClick) voidsetFileHandler(com.vaadin.flow.function.SerializableConsumer<OutputStream> contentWriter) voidsetFileName(String fileName) Methods inherited from class com.vaadin.flow.component.html.Anchor
getHref, getTarget, getTargetValue, isRouterIgnore, onEnabledStateChanged, removeHref, setHref, setHref, setRouterIgnore, setTarget, setTargetMethods inherited from class com.vaadin.flow.component.HtmlComponent
getTitle, setTitleMethods 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, removeFromParent, scrollIntoView, 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.BlurNotifier
addBlurListenerMethods inherited from interface com.vaadin.flow.component.DetachNotifier
addDetachListenerMethods inherited from interface org.vaadin.firitin.fluency.ui.FluentAttachNotifier
withAttachListenerMethods inherited from interface org.vaadin.firitin.fluency.ui.FluentComponent
setId, setVisible, withId, withVisibleMethods inherited from interface org.vaadin.firitin.fluency.ui.FluentDetachNotifier
withDetachListenerMethods inherited from interface org.vaadin.firitin.fluency.ui.FluentHasEnabled
withEnabledMethods inherited from interface com.vaadin.flow.component.Focusable
addFocusShortcut, blur, focus, getTabIndex, setTabIndexMethods inherited from interface com.vaadin.flow.component.FocusNotifier
addFocusListenerMethods inherited from interface com.vaadin.flow.component.HasAriaLabel
getAriaLabel, getAriaLabelledBy, setAriaLabel, setAriaLabelledByMethods inherited from interface com.vaadin.flow.component.HasComponents
add, add, add, addComponentAsFirst, addComponentAtIndex, remove, remove, removeAllMethods inherited from interface com.vaadin.flow.component.HasElement
getElementMethods inherited from interface com.vaadin.flow.component.HasEnabled
isEnabled, setEnabledMethods 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, setWidthFullMethods inherited from interface com.vaadin.flow.component.HasStyle
addClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassNameMethods inherited from interface com.vaadin.flow.component.HasText
getText, getWhiteSpace, setText, setWhiteSpace
-
Field Details
-
requestHandler
protected com.vaadin.flow.server.RequestHandler requestHandler
-
-
Constructor Details
-
DynamicFileDownloader
public DynamicFileDownloader(String text, String fileName, com.vaadin.flow.function.SerializableConsumer<OutputStream> contentWriter) -
DynamicFileDownloader
public DynamicFileDownloader(com.vaadin.flow.component.Component downloadComponent, String fileName, com.vaadin.flow.function.SerializableConsumer<OutputStream> contentWriter) -
DynamicFileDownloader
public DynamicFileDownloader()
-
-
Method Details
-
setDisableOnClick
public void setDisableOnClick(boolean disableOnClick) -
onAttach
protected void onAttach(com.vaadin.flow.component.AttachEvent attachEvent) - Overrides:
onAttachin classcom.vaadin.flow.component.Component
-
onDetach
protected void onDetach(com.vaadin.flow.component.DetachEvent detachEvent) - Overrides:
onDetachin classcom.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 @Pushin use or useUI.setPollInterval(int)method.- Parameters:
listener- the listener- Returns:
- the
Registrationyou can use to remove this listener.
-
addDownloadFailedListener
public com.vaadin.flow.shared.Registration addDownloadFailedListener(com.vaadin.flow.component.ComponentEventListener<DynamicFileDownloader.DownlocadFailedEvent> listener) Adds a listener that is executed when the file content streaming has failed due to an exception. 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.
-
setFileHandler
public void setFileHandler(com.vaadin.flow.function.SerializableConsumer<OutputStream> contentWriter) -
setFileName
-
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 sessionrequest- the vaadin request- Returns:
- the file name
-
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
-