OptionsGroup set preselected items

Hi,

I have 2 entities: Employeer(name,positions) and Position(title).
I have one-to-many relationship between them, the employeer can have many positions.
I added an optionsgroup component with the positions in the employeer editor page.
How can I prefill the selected items from this group when editing an employeer?
I thought something like

employeerDs.refresh();
Employeer x = employeerDs.getItem();
optionsGroupPositions.setValue(employeerDs.getItem().getPositions());

But I get null pointer for the employeer datasource…

Solved it, within the postInit method, the datasource is initialized after the init method.

1 Like