2017-04-03 118 views
0

如何檢測fileDownloader完成導出我的CSV文件:如何檢測時FileDownloader在vaadin完成

這裏的一部分,在那裏我實現了下載按鈕

Button downloadButton = new Button("Download"); 
    Exporter exporter = new Exporter(); 
    downloadButton.addClickListener(clickEvent -> { 
    //something here 
    }); 
    exporter.getFileDownloader().extend(downloadButton); 

我的出口商與fileDownloader:

class Exporter{ 
    private FileDownloader fileDownloader; 

    Exporter() { 
     StreamResource streamResource = createResource(); 
     fileDownloader = new FileDownloader(streamResource); 
    } 

    private StreamResource createResource() { 
     return new StreamResource(new StreamResource.StreamSource() { 
      @Override 
      public InputStream getStream() { 
      // some logic here 
      } 
     }, "myfile.csv"); 
    } 

    FileDownloader getFileDownloader() { 
     return fileDownloader; 
    } 

    ... 
+0

你可以嘗試包裝輸入流 –

回答