HI,
I have a CustomFileDescriptor Entity that is replacing the normal FileDescriptor. The CustomFileDescriptor has a couple of extra attributes.
I then have a Document Entity that has one string column and a composition link to the CustomFileDescriptor.
I have created a Screen for Browse and Edit of the Document Entity.
The edit screen I have removed the CustomFileDescriptor field from the FieldGroup and replaced this with some UI and code I got from following the Documentation on how to do a Manual upload. I’m doing the Manual upload because I want to set my custom properties on the CustomFileDescriptor Entity. I need these for my own file API implementation for FileCloud which was based off of the AWS code in CUBA.
This is the code in my edit screen
`
@Override
public void init(Map<String, Object> params) {
uploadField.addFileUploadSucceedListener(event -> {
FileDescriptor fd = uploadField.getFileDescriptor();
CustomFileDescriptor cfd = (CustomFileDescriptor)fd;
try {
// save file to FileStorage
cfd.setCustomField("WOOHOOOOO");
fileUploadingAPI.putFileIntoStorage(uploadField.getFileId(), fd);
} catch (FileStorageException e) {
throw new RuntimeException("Error saving file to FileStorage", e);
}
// save file descriptor to database
dataSupplier.commit(fd);
showNotification("Uploaded file: " + uploadField.getFileName(), NotificationType.HUMANIZED);
});
uploadField.addFileUploadErrorListener(event ->
showNotification("File upload error", NotificationType.HUMANIZED));
}
`
and this is my screen layout
`
<layout expand="windowActions"
spacing="true">
<fieldGroup id="fieldGroup"
datasource="customFilesTestDs">
<column width="250px">
<field property="someImportantInfo"/>
</column>
</fieldGroup>
<upload id="uploadField"
clearButtonIcon="PICKERFIELD_CLEAR"
datasource="customFilesTestDs"
dropZone="dropZone"
property="fileLink"
showClearButton="true"
showFileName="true"
uploadButtonIcon="CLOUD_UPLOAD"/>
<vbox id="dropZone"
height="150px"
spacing="true"
stylename="dropzone-container">
<label align="MIDDLE_CENTER"
stylename="dropzone-description"
value="Drop file here"/>
</vbox>
<frame id="windowActions"
screen="editWindowActions"/>
</layout>
`
I’m getting this error.
I have tried both Composition and Association link to the CustomFileDescriptor, I have also tried commenting out this line of code dataSupplier.commit(fd);
thinking the OK action would take care of it. I have linked the FileUpload to the dataset and property.
Nothing seems to make a difference.
Can anyone help?