Enum Class DownloadTarget

java.lang.Object
java.lang.Enum<DownloadTarget>
com.vaadin.flow.component.download.DownloadTarget
All Implemented Interfaces:
Serializable, Comparable<DownloadTarget>, Constable

public enum DownloadTarget extends Enum<DownloadTarget>
Where the browser puts the content of a Download.
  • Enum Constant Details

    • SAVE_AS_FILE

      public static final DownloadTarget SAVE_AS_FILE
      Saves the content as a file, as the browser does for any download. Content from a handler or another URL of the same origin is saved even if it is served inline, for example by a handler on which inline() was called. For a URL of another origin, the server of that URL decides: content it serves inline may be shown instead of saved.
    • NEW_TAB

      public static final DownloadTarget NEW_TAB
      Opens the content in a new browser tab. The browser shows the content when it can, for example a PDF, an image or plain text, and saves it as a file otherwise.

      A built-in handler, such as one from DownloadHandler.forFile, is switched to serve its content inline, and this can not be undone. Do not reuse that handler instance where the content should be downloaded instead, for example in an Anchor: there the browser would show the content instead of saving it. Create a separate handler for each use instead. Another Download with SAVE_AS_FILE can share the handler, since it saves the content regardless.

      The new tab is opened without access to the opening page (noopener) and without a Referer header (noreferrer).

  • Method Details

    • values

      public static DownloadTarget[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static DownloadTarget valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null