01-16-2017 09:05 PM
Hi All,
Need your help with this one. Has anyone tried downloading a file in activiti BPM?
I'm new with activity BPM and original developer of the code created a customised button to retrieve csv files in activiti BPM as below.
public void buttonClick(ClickEvent event) {
logger.info("preparing download resource");
String csvdata = formProperty.getValue();
// the first line is the filename
filename = csvdata.substring(0, csvdata.indexOf('\r'));
csvdata = csvdata.substring(csvdata.indexOf('\r') + 2, csvdata.length());
logger.info("downloading file " + filename);
StreamResource resource = new StreamResource(new StringStreamSource(csvdata), filename, ExplorerApp.get());
resource.setMIMEType("text/plain");
ExplorerApp.get().getMainWindow().open(resource,"downloadWindow");
//downloadWindow.setVisible(true);
}
The code currently opens a new window. I'm looking for a way to download the file/open as a download dialog instead.
I tried to use FileDownloader but I think it clashed with the UI of activiti and I had the error below.
Caused by: java.lang.VerifyError: Bad type on operand stack
Exception Details:
Location:
com/vaadin/server/FileDownloader.extend(Lcom/vaadin/ui/AbstractComponentV @2: invokespecial
Reason:
Type 'com/vaadin/ui/AbstractComponent' (current frame, stack[1]) is not assignable to 'com/vaadin/server/AbstractClientConnector'
Current Frame:
bci: @2
flags: { }
locals: { 'com/vaadin/server/FileDownloader', 'com/vaadin/ui/AbstractComponent' }
stack: { 'com/vaadin/server/FileDownloader', 'com/vaadin/ui/AbstractComponent' }
Bytecode:
Does anyone have any idea on how to incorporate the vaadin FileDownloader with the activity BPM UI?
01-18-2017 12:42 PM
01-18-2017 03:09 PM
Hi Greg
Thanks for your reply. That doesn't seem to work though. In my case, a new window is opened instead.
public void buttonClick(ClickEvent event) {
logger.info("preparing download resource");
String csvdata = formProperty.getValue();
// the first line is the filename
filename = csvdata.substring(0, csvdata.indexOf('\r'));
csvdata = csvdata.substring(csvdata.indexOf('\r') + 2, csvdata.length());
logger.info("downloading file " + filename);
StreamResource resource = new StreamResource(new StringStreamSource(csvdata), filename, ExplorerApp.get());
// resource.setMIMEType("text/plain");
resource.setMIMEType("application/octet-stream");
ExplorerApp.get().getMainWindow().open(resource,"downloadWindow");
//downloadWindow.setVisible(true);
}
Regards,
Mark
01-18-2017 05:35 PM
Hmm, ok. Havent spent much time with the explorer app.
Probably need to play around with it. I don't suppose you can attach your project?
01-19-2017 05:17 PM
Hi,
I don't think I can.
Although, would you think the one you advised me with won't work in vaadin 6.8.8? That's the current version I have now.
Explore our Alfresco products with the links below. Use labels to filter content by product module.