use of org.olat.modules.forms.ui.model.FileUploadWrapper in project openolat by klemens.
the class EvaluationFormController method forgeFileUpload.
private EvaluationFormElementWrapper forgeFileUpload(UserRequest ureq, FileUpload element) {
FileElement fileEl = uifactory.addFileElement(getWindowControl(), "file_upload_" + CodeHelper.getRAMUniqueID(), "", flc);
fileEl.setPreview(ureq.getUserSession(), true);
fileEl.addActionListener(FormEvent.ONCHANGE);
fileEl.setDeleteEnabled(true);
fileEl.setMaxUploadSizeKB(element.getMaxUploadSizeKB(), "file.upload.error.limit.exeeded", null);
Set<String> mimeTypes = MimeTypeSetFactory.getMimeTypes(element.getMimeTypeSetKey());
fileEl.limitToMimeType(mimeTypes, "file.upload.error.mime.type.wrong", null);
EvaluationFormResponse response = identifierToResponses.get(element.getId());
File responseFile = evaluationFormManager.loadResponseFile(response);
if (responseFile != null) {
fileEl.setInitialFile(responseFile);
}
fileEl.setEnabled(!readOnly);
FileUploadWrapper fileUploadWrapper = new FileUploadWrapper(fileEl, element);
fileEl.setUserObject(fileUploadWrapper);
EvaluationFormElementWrapper wrapper = new EvaluationFormElementWrapper(element);
wrapper.setFileUploadWrapper(fileUploadWrapper);
return wrapper;
}
Aggregations