CUBA 7.2, Legacy GUI
На экране сущности ExtSimpleDoc есть DataGrid и SuggestionField. После поиска нужной сущности через SuggestionField идет программное добавление строки в CollectionDatasource и соответственно в связанный с ней DataGrid
Часть экрана ExtSimpleDoc:
<dsContext>
<datasource id="cardDs" class="com.dtm.entity.ExtSimpleDoc">
<collectionDatasource id="sellersDs" property="sellers2"/>
</datasource>
</dsContext>
....
<dataGrid id="sellersTable"
datasource="sellersDs"
width="100%"
height="300"
emptyStateMessage="mainMsg://AddEmployee"
editorEnabled="false"
settingsEnabled="false"
columnsCollapsingAllowed="false"
selectionMode="MULTI">
<columns>
<column property="name" caption="mainMsg://ExtEmployee"/>
</columns>
<actions>
<action id="add" type="add"/>
<action id="refresh" type="refresh"/>
<action id="remove" type="remove"/>
</actions>
<buttonsPanel alwaysVisible="true">
<button id="addBtn" action="sellersTable.add" icon="ts-font-icon:PLUS"/>
<button id="removeBtn" action="sellersTable.remove"/>
<suggestionField id="findField">
<query entityClass="com.dtm.entity.ExtEmployee"
escapeValueForLike="true"
searchStringFormat="%$searchString%">
select c from dtm$ExtEmployee c where lower(c.name) like lower(:searchString) escape '\'
</query>
</suggestionField>
</buttonsPanel>
</dataGrid >
....
обработчик экрана:
@Inject
private SuggestionField<ExtEmployee> findField;
@Inject
private DataGrid<ExtEmployee> sellersTable;
@Inject
private CollectionDatasource<ExtEmployee, UUID> sellersDs;
@Subscribe
protected void onInit(InitEvent event) {
findField.addValueChangeListener(changeEvent ->{
ExtEmployee newEmployee = changeEvent.getValue();
if (newEmployee != null) {
sellersDs.addItem(newEmployee);
findField.setValue(null);
}
});
}
Проблема в том, что программно добавленные строки не сохраняются при сохранении основной сущности экрана (ExtSimpleDoc).
При этом добавленные по кнопке (actions Add) сохраняются нормально.
Смотрел отладчиком, вызывается одна и та же функция CollectionPropertyDatasourceImpl.addItem() в обоих случаях. В контексте данные помечены как модифицированные.
Подскажите в чем проблема может быть?