use of com.vaadin.ui.Upload.Receiver in project Activiti by Activiti.
the class FileAttachmentEditorComponent method initFileUpload.
protected void initFileUpload() {
uploadComponent = ExplorerApp.get().getComponentFactory(UploadComponentFactory.class).create();
Receiver receiver = new Receiver() {
private static final long serialVersionUID = 1L;
public OutputStream receiveUpload(String filename, String mType) {
fileName = filename;
// Try extracting the extention as well, and append it to the mime-type
String extention = extractExtention(filename);
if (extention != null) {
mimeType = mType + MIME_TYPE_EXTENTION_SPLIT_CHAR + extention;
} else {
mimeType = mType;
}
// TODO: Refactor, don't use BAOS!!
byteArrayOutputStream = new ByteArrayOutputStream();
return byteArrayOutputStream;
}
};
uploadComponent.setReceiver(receiver);
uploadComponent.addFinishedListener(new FinishedListener() {
private static final long serialVersionUID = 1L;
public void uploadFinished(FinishedEvent event) {
// Update UI
if (getAttachmentName() == null || "".equals(getAttachmentName())) {
setAttachmentName(getFriendlyName(fileName));
}
fileUploaded = true;
successIndicator.setVisible(true);
successIndicator.setCaption(i18nManager.getMessage(Messages.RELATED_CONTENT_TYPE_FILE_UPLOADED, fileName));
form.setComponentError(null);
}
});
addComponent(uploadComponent);
setExpandRatio(uploadComponent, 1.0f);
}
Aggregations