download file in activiti UI (vaadin 6)

cancel
Showing results for 
Search instead for 
Did you mean: 
msaballa
Member II

download file in activiti UI (vaadin 6)

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/AbstractComponentSmiley WinkV @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?

4 Replies
gdharley
Intermediate

Re: download file in activiti UI

Rathe than answering the question you ultimately ask, I think the easiest way for you to force a save to file dialogue is to simply change the mime type from text/plain to application/octet-stream or some other mime type that is perceived to be binary.

Cheers,

Greg

msaballa
Member II

Re: download file in activiti UI

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

gdharley
Intermediate

Re: download file in activiti UI

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?

msaballa
Member II

Re: download file in activiti UI (vaadin 6)

Hi,

 

I don't think I can. Smiley Sad

 

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.