I have created a master-detail UI and can insert new records, save in the detail table directly (inline edit). However, the master reference is not saved as i am using the datasource of detail. I am using the following codes in controller. Any help in correcting it to populate the master key in detail table
@Inject
private CollectionDatasource<ProductionGrLines, UUID> linesDs;
@Inject
private Metadata metadata;
@Override
public void init(Map<String, Object> params) {
}
public void onAdd(Component source) {
linesDs.addItem(metadata.create(ProductionGrLines.class));
}
public void onRemove(Component source) {
if (linesDs.getItem() != null) {
linesDs.removeItem(linesDs.getItem());
}
}
public void onSave() {
if (validateAll()) {
getDsContext().commit();
showNotification(getMessage("changesSaved"), NotificationType.HUMANIZED);
}
}
@Override
public boolean validateAll() {
for (ProductionGrLines task : linesDs.getItems()) {
if (task.getArticle() == null ) {
showNotification(getMessage("fillRequiredFields"), NotificationType.TRAY);
return false;
}
}
return super.validateAll();
}