Init Table with Composition-linked Entities

Hi, I need to init Table Component (contains Composition-linked Entities) in new Master Entity Editor Screen
sample code?

I tried, but no effect;

@Subscribe
public void onInitEntity(InitEntityEvent<InitialVisit> event) {
    List<InitialPhysicalExamination> examinationList = new ArrayList<>();

    InitialPhysicalExamination e = dataManager.create(InitialPhysicalExamination.class);
    PhysicalExamination pe = dataManager.create(PhysicalExamination.class);
    pe.setInspection("КОЖА");
    e.setPhysicalExamination(pe);
    e.setInitialVisit(event.getEntity());

    examinationList.add(e);

    physicalExaminationDc.setItems(examinationList);
}

It is would be useful to see a descriptor of the screen for precise understanding your code.

I can assume, that essence e and pe are not kept in a DB from your screen.

If you create an entity using ‘dataManager.create’, it will not be automatically tracked in screen context and not stored in DB from screen automatically .

Or use ‘dataContext.create(InitialPhysicalExamination.class)’ - it will immediately add a new entity to the context of the screen.
Or explicitly add new entities to datacontext - ‘dataContext.merge(e)’.

1 Like