neutrino36
(neutrino neutrino)
June 29, 2020, 10:41am
#1
Hello Team,
I tried to set and commit an Entity (Transaction) status after a button clicked but I have this error:
I called a service like:
if(logic){
datamanager.commit();
}
and in Browse Interface:
if( statusService.completeStatus(transations)){
// transactionsDl.load();
getScreenData().loadAll();
}
If I reopen the screen the modification is done!
Please advise!
neutrino36
(neutrino neutrino)
June 29, 2020, 11:23am
#2
I used invoked method from Button settings. Is better to subscribe to ActionPerformed Event?
krivopustov
(Konstantin Krivopustov)
June 30, 2020, 7:19am
#3
Most probably you have to set the saved entity instance back to the screen data components like this:
if (logic) {
MyEntity saved = dataManager.commit(myEntity);
dataContext.merge(saved);
}
neutrino36
(neutrino neutrino)
June 30, 2020, 7:40am
#4
It worked!!
Meantime I used commitContext.addInstanceToCommit (MyEntity)
that works as well but is no such consistent (maybe I have to use view
as well).
Please explain a little bit the saving mechanism: why do I need to set saved entity instance back to the screen?
What are the differences between commitContext
and dataContext
?
getScreenData().loadAll();
is still necessary?
Thank you very much!
-n
neutrino36
(neutrino neutrino)
June 30, 2020, 11:32am
#5
Unfortunately, randomly, the error reappears.
Set<Transaction> trans = transactionsTable.getSelected();
for(Transaction a: trans){
if (logic) {
a.setStatus(statusone);
// commitContext.addInstanceToCommit(a);
Transaction saved = dataManager.commit(a);
dataContext.merge(saved);
}
if (logic) {
a.setStatus(statustwo);
// commitContext.addInstanceToCommit(a);
Transaction saved = dataManager.commit(a);
dataContext.merge(saved);
}
}
Result of dataContext.merge(saved)
is ignored…