commiting External files into object not working

Hi,

I have a Object which has a value FileDescriptor List property.


@JoinTable(name = "EQUIPMENTCHECKLIST_DEVIATION_INPUT_FILE_DESCRIPTOR_LINK",
        joinColumns = @JoinColumn(name = "DEVIATION_INPUT_ID"),
        inverseJoinColumns = @JoinColumn(name = "FILE_DESCRIPTOR_ID"))
@ManyToMany
protected List<FileDescriptor> pics;

What I would like to do is update that list(which is a list of FileDescriptor when looking from the UI ) by uploading the file first into temporary rep. then commit it once the main Object is committed successfully.
The problem is that files are committed into External Files but not attached at the Object.

 
uploadField.addFileUploadSucceedListener

is successful then I’m doing


listOfPics.add(fd); //local param to distinguish freshly uploaded files with already existing
getItem().getPics().add(fd);

then in


@Override
protected boolean preCommit() {
    if (getItem().getPics() !=null) {
        for (FileDescriptor fd : listOfPics) {
           getItem().getPics().add(dataSupplier.commit(fd));
        }
    }
    return  super.preCommit();
}

could you help me figure out what’s the problem there?

Resolved it.
Since it was a list of Files, so a table, in you editor you should have

protected Table<FileDescriptor> picsTable;

and populate pics when the file is uploaded to temporary repository with :

picsTable.getDatasource().addItem(fd);

It will commit everything to External File once the you Custom Entity has been committed.

Hi,

You are right. If you want to commit Many-to-Many relation instances with your main entity they must be added to datasource, because data sources track changes and pass data to middle ware on editor commit.

1 Like