Example usage for com.vaadin.server FileDownloader FileDownloader

List of usage examples for com.vaadin.server FileDownloader FileDownloader

Introduction

In this page you can find the example usage for com.vaadin.server FileDownloader FileDownloader.

Prototype

public FileDownloader(Resource resource) 

Source Link

Document

Creates a new file downloader for the given resource.

Usage

From source file:views.StandaloneTSVImport.java

License:Open Source License

private Component createTSVDownloadComponent(DesignType type, String info) {
    VerticalLayout v = new VerticalLayout();
    v.setSpacing(true);/* www  .  j a v a 2s. co m*/
    Label l = new Label(info);
    l.setWidth("300px");
    v.addComponent(l);
    Button button = new Button("Download Example");
    v.addComponent(button);

    String basepath = VaadinService.getCurrent().getBaseDirectory().getAbsolutePath();
    FileDownloader tsvDL = new FileDownloader(
            new FileResource(new File(basepath + "/WEB-INF/files/" + type.getFileName())));
    tsvDL.extend(button);

    return v;
}

From source file:views.StandaloneTSVImport.java

License:Open Source License

public void setTSVWithBarcodes(String tsvContent, String name) {
    if (downloadTSV != null)
        removeComponent(downloadTSV);/* ww w  .j a v  a  2s  . c o  m*/
    downloadTSV = new Button("Download Barcodes");
    addComponent(downloadTSV);
    FileDownloader tsvDL = new FileDownloader(Functions.getFileStream(tsvContent, name, "tsv"));
    tsvDL.extend(downloadTSV);
}