I am in a edit screen for entity A. On this edit screen, there is a collection of properties in a table for entity B.
There is a button that takes the user to the editor screen for entity B. I want to reload the table that has the collection of entity B values after close and committing from the editor screen for entity B.
It uses a generated column with a button in it to get to the entity B editor screen.
@Subscribe
public void onBeforeShow(BeforeShowEvent event) {
assignmentsTable.addGeneratedColumn("columnID", entity -> {
Label label = uiComponents.create(Label.class);
if (entity.getValueA() != null && entity.getValueB() != null) {
//do something
label.setValue(valueA + valueB);
} else {
label.setValue("Absent");
}
return label;
});
if (!isReadOnly()) {
assignmentsTable.addGeneratedColumn("Options", entity -> {
Button editBtn = uiComponents.create(Button.class);
editBtn.addClickListener(e -> {
screenBuilders.editor(EnitityB.class, this)
.withScreenClass(EnitityB_Editor.class)
.editEntity(entity)
.show()
.addAfterCloseListener(afterCloseEvent -> entityA_Dl.load());
});
editBtn.setCaption("Edit");
return editBtn;
});
}
}
After the second EnitityB_Editor is closed, i need the label in to be set to “Absent” if values A and B was set to null.
there is another value, valueC, that actually changed and is shown correctly.
I thought using addAfterCloseListener(afterCloseEvent -> entityA_Dl.load());
would work but it did not.
below is the code that changes the value in Entity B’s Editor screen controller:
@Subscribe("isAbsentField")
public void onIsAbsentFieldValueChange(HasValue.ValueChangeEvent<Boolean> event) {
if (isAbsentField.isChecked()) {
valueA.setEditable(false);
valueB.setEditable(false);
getEditedEntity().valueC(0L); //this value was updated and is shown correctly when the editor is closed
//THESE ARE THE ONES THAT ONLY SHOW CORRECTLY AFTER THE EDITOR SCREEN FOR ENTITY A IS CLOSED
getEditedEntity().valueA(null);
getEditedEntity().valueb(null);
}
else {
valueA.setEditable(true);
valueb.setEditable(true);
}
}
Entity B is a property of Entity A and is retrieved using a CollectionPropertyContainer
and so i cannot reload this collection, that why I thought to put a reload on the loader for Entity A.
<instance id="entityA_Dc"
class="com.company.app.entity.entityA"
view="entityA-view">
<loader id="entityA_Dl"/> //reload this to refresh the below
<collection id="entityB_Dc" property="entityB"/>
</instance>