Добрый день!
Пытаюсь программно создать связанную сущность (нашел аналогичный вопрос). Вроде бы все понятно, но почемуто при вызове postInit получаю enclosesDs=null.
Делаю так:
public class UUIDInvoiceEdit extends AbstractEditor<UUIDInvoice> {
@Inject
private GeneratorService gcserv;
@Inject
private CollectionDatasource<UUIDEnclose, UUID> enclosesDs;
@Override
protected void initNewItem(UUIDInvoice item){
item.setInvoicenumber(gcserv.GenerateInvoiceNumber(GenType.InvoiceNumber));
}
@Override
protected void postInit() {
enclosesDs.setItem(getItem().getEncloses().iterator().next());
}
}
и текст разметки:
<window xmlns="http://schemas.haulmont.com/cuba/window.xsd"
caption="msg://editCaption"
class="com.company.invoicecreate.gui.uuidinvoice.UUIDInvoiceEdit"
datasource="uUIDInvoiceDs"
focusComponent="fieldGroup"
messagesPack="com.company.invoicecreate.gui.uuidinvoice">
<dsContext>
<datasource id="uUIDInvoiceDs"
class="com.company.invoicecreate.entity.UUIDInvoice"
view="uUIDInvoice-view">
<collectionDatasource id="enclosesDs"
property="encloses"/>
</datasource>
</dsContext>
<layout expand="windowActions"
spacing="true">
<fieldGroup id="fieldGroup"
datasource="uUIDInvoiceDs">
<column width="250px">
<field id="invoicenumber"/>
<field id="gcinvoicenuber"/>
<field id="receiptdt"/>
</column>
</fieldGroup>
<groupBox id="enclosesBox"
caption="msg://com.company.invoicecreate.entity/UUIDInvoice.encloses">
<table id="enclosesTable"
height="200px"
width="100%">
<actions>
<action id="create"/>
<action id="edit"/>
<action id="remove"/>
</actions>
<columns>
<column id="barcode"/>
</columns>
<rows datasource="enclosesDs"/>
<buttonsPanel>
<button action="enclosesTable.create"/>
<button action="enclosesTable.edit"/>
<button action="enclosesTable.remove"/>
</buttonsPanel>
</table>
</groupBox>
<frame id="windowActions"
screen="editWindowActions"/>
</layout>
</window>
Подскажите в чем причина?
Спасибо!