Hi! i am trying to update an items table after create action is called, but new item not appear until i commit data and reopen screen, i have next code:
Hi @marc.delphi,
In your code, you open an edit screen with Parent DataContext
, which should commit data to the current screen’s data context. Thus, all changes will be saved in parent DataContext (ArticuloConfig DataContext
), not in the ArticuloConfigItem DataContext
.
Remove the withParentDataContext(articuloConfigItemsDl.getDataContext())
line and it will work.
In addition, you can delete screenBuilders.build()
call because screenBuilders.show()
method already contains this call.
I put a link to documentation, where you can find additional information about Parent DataContext
.
Regards,
Gleb
Hi, that is exaclty what i want to do. i want to commit changes from child entities on its parent context… in old framework i did something like this:
public class AlicuotaIVAEdit extends AlicuotaEdit {
@Inject
private GroupBoxLayout valoresBox;
@Inject
private WindowConfig windowConfig;
@Inject
private Metadata metadata;
@Inject
private CollectionDatasource<AlicuotaValorIVA, IdProxy<Long>> alicuotaValorIVAsDs;
public void onCreate(Component source) {
AlicuotaValorIVA alicuotaValor = metadata.create(AlicuotaValorIVA.class);
String windowAlias = windowConfig.getEditorScreenId(alicuotaValor.getMetaClass());
alicuotaValor.setAlicuota(this.getItem());
alicuotaValorIVAsDs.setItem(alicuotaValor);
openEditor(windowAlias, alicuotaValor, WindowManager.OpenType.NEW_TAB, alicuotaValorIVAsDs)
.addCloseWithCommitListener(() -> {
alicuotaValorIVAsDs.refresh();
});
}
}
Replace a screenBuilders.addAfterCloseListener()
call with screenBuilders.withListComponent(itemsTable)
call.
Regards,
Gleb