Class DownloadLink

    • Constructor Detail

      • DownloadLink

        public DownloadLink​(String id,
                            File file)
        Constructor. File name used will be the result of file.getName()
        Parameters:
        id - component id
        file - file to stream to client
      • DownloadLink

        public DownloadLink​(String id,
                            IModel<File> model)
        Constructor. File name used will be the result of file.getName()
        Parameters:
        id - component id
        model - model that contains the file object
      • DownloadLink

        public DownloadLink​(String id,
                            IModel<File> model,
                            String fileName)
        Constructor. File name used will be the result of file.getName()
        Parameters:
        id - component id
        model - model that contains the file object
        fileName - name of the file
      • DownloadLink

        public DownloadLink​(String id,
                            File file,
                            String fileName)
        Constructor
        Parameters:
        id - component id
        file - file to stream to client
        fileName - name of the file
      • DownloadLink

        public DownloadLink​(String id,
                            IModel<File> fileModel,
                            IModel<String> fileNameModel)
        Constructor. File name used will be the result of file.getName()
        Parameters:
        id - component id
        fileModel - model that contains the file object
        fileNameModel - model that provides the file name to use in the response headers
    • Method Detail

      • onClick

        public void onClick()
        Description copied from class: Link
        Called when a link is clicked.
        Specified by:
        onClick in class Link<File>
      • setDeleteAfterDownload

        public final DownloadLink setDeleteAfterDownload​(boolean deleteAfter)
        USE THIS METHOD WITH CAUTION! If true, the file will be deleted! The recommended way to use this setting, is to set this DownloadLink object's model with a LoadableDetachableModel instance and the resulting file being generated in a temporary folder.
        Parameters:
        deleteAfter - true to delete file after download succeeds
        Returns:
        this component
      • setCacheDuration

        public DownloadLink setCacheDuration​(Duration duration)
        Sets the duration for which the file resource should be cached by the client.
        Parameters:
        duration - the duration to cache
        Returns:
        this component.