Hi,
In my webapp, the user can generate and download a report. This happens when the user presses download, and unfortuanly when creating the streamsource, the whole webapp hangs, and I just can’t figure out why. Since the operation of generating the report can take up to 30 seconds to generate, I’m not the most popular man at the minute!
Whenever the user chooses to see testresults, the following button is made:
private Button createExportButton(String caption, String filename, StreamSource ss)
{
Button b = new Button(caption);
FileDownloader downloader = new FileDownloader(new StreamResource(ss, filename));
downloader.extend(b);
return b;
}
And the StreamSource is as following:
private StreamSource createPdfStreamSource()
{
return new StreamSource() {
@Override public InputStream getStream()
{
List<Chart> allCHarts = new ArrayList<>();
List<testSpecifics> linecspecs = new ArrayList<>();
for(com.vaadin.ui.Component component : graphLayout){
try{
Chart chart = (Chart)component;
allCHarts.add(chart);
} catch(Exception e) {// I know - sry}
}
try {
return new FileInputStream(new ResultPdfRGenerator().makePdf(allCHarts, currentSpecs, conctest, (Test)testChooser.getValue()));
} catch (FileNotFoundException e)
{ e.printStackTrace();
}
return null; } };
}
Can any of you point me in the right direction, for
not
making this block the UI? The pdfGenerator is the slow thing here. I really hope you can help me here
I guess I could create the report in the background such that it is ready for the user, but it’s only about 10% of the time, that the user actually needs the report, so I don’t think that will be a good idea.
Anyway, I’m keeping my fingers crossed!
Have a great week guys.
Best regards
Ben