Editable table remove action

Hi!

I encountered a problem with editable tables.
My table shows entities with a required field. It is set to be editable and the columns are also set to be editable.
If I select an entity that is already saved in the database the remove action gets enabled.
After this if I delete the required fields (name) content and choose the remove action I get an exception:

SQLIntegrityConstraintViolationException: integrity constraint violation: NOT NULL check constraint; SYS_CT_10390 table: UNTITLED_NEW_ENTITY column: NAME

As I understand the remove action just runs an update on the database with the deleted_by and delete_ts set. So the problem is the other fields value are not those saved in the database but the ones shown in the table.

Can you suggest a way to avoid this error?

Thanks,
Julia

1 Like

This is a really good question, I have the same problem with my application as well, I hope it can be fixed easily. I am looking forward to an answer from the fantastic developers of the Cuba platform.

Regards,
Attila

1 Like

Hi,

Try to reload the entity you want to remove and then remove the reloaded entity. In this case, the removed entity will have values prior editing and marked as deleted.

Thank you for your answer Gleb Gorelov!
Yeah it seems like the simplest way…

@Named("newEntitiesTable.remove")
private Action removeAction;

@Inject
private GroupTable newEntitiesTable;

public void customRemove() {
    newEntitiesTable.refresh();
    removeAction.actionPerform(newEntitiesTable);
}

I hoped there would be a generic solution, I have many tables like this…