Hello, i’m having an issue updating an inner datasource in my app.
I create an outer entity, which consists of other entities, let’s say order
and orderline
's (one-to-many, composition). So i want to edit orderlines
right from my order
edit screen, where i show order
info, a table of orderline
s and and a groupbox with orderline
's properties. The only exception from the default implementation is that my edit
button is custom.
Everything goes fine while i don’t try to edit existing orderline
from that big order
edit screen. as i press OK
button in orderline
editor - nothing happens on order
editor screen (but if i enter orderline
editor again - i see edited property).
I already added a couple of datasource refreshers in close-with-commit listener but nothing worked… I’ll attach my sample project for you to see, if you don’t mind
properties-proxy-show.zip (80.3 KB)
Hi Ivan,
What is the reason for you to use a custom action? You could have used the standard EditAction and customize it for your needs, and no additional logic for refreshing the datasource is needed in this case.
Just a topic for inspiration.
As for your sample, to refresh the inner datasource, you need to refresh the parent datasource as well. So, the OuterEntityEdit
code may look like this:
public class OuterEntityEdit extends AbstractEditor<OuterEntity> {
@Inject
private GroupDatasource<ComplexEntity, UUID> entriesDs;
@Inject
private Datasource<OuterEntity> outerEntityDs;
@Inject
private Table<ComplexEntity> entriesTable;
@Inject
private TextField tfd;
@Inject
private TextField tfi;
@Inject
private TextField tfs;
public void onCustomEdit() {
ComplexEntity entry = entriesTable.getSingleSelected();
if (entry == null) return;
AbstractEditor editor = openEditor(entry, WindowManager.OpenType.DIALOG);
editor.addCloseWithCommitListener(() -> {
outerEntityDs.refresh();
entriesDs.refresh();
tfd.setValue(entriesDs.getItem(entry.getId()).getPropDate());
tfs.setValue(entriesDs.getItem(entry.getId()).getPropString());
tfi.setValue(entriesDs.getItem(entry.getId()).getPropInt());
});
}
}
I use a custom action, cos in my main project the standard EditAction
is used for other case. Thanks for the answer, i’ll try it