I want to show in my document a one-to-many relationship- a simple drop-down list with values. For that, I trying to create and configure LookupField
component by using Cuba platform.
I have two entities:
CardItem:
@NamePattern("The document in the following state: %s|cardState")
@Table(name = "TKB_CARD_ITEM")
@Entity(name = "tkb$CardItem")
public class CardItem extends StandardEntity {
// skipped
CardType:
@NamePattern("CardType: %s, %s |cardTypeItem, cardTypeName")
@Table(name = "TKB_CARD_TYPE")
@Entity(name = "tkb$CardType")
public class CardType extends StandardEntity {
@OneToMany(targetEntity=CardItem.class )
private List<CardItem> cardItems;
// skipped
In my card-item-edit.xml
I have the following:
<dsContext>
<datasource id="CardItemDs" class="com.company.tkb.entity.CardItem" view="_local"/>
<collectionDatasource id="CardTypeDs" class="com.company.tkb.entity.CardType" view="_local">
<query>select c from tkb$CardType c</query>
</collectionDatasource>
</dsContext>
<layout>
<lookupField datasource="CardItemDs" property="cardTypeName" optionsDatasource="CardTypeDs"/>
I filled the table TKB_CARD_TYPE
with some values. Now I'm trying to get a drop-down list with values when I create CardItem, but the list is empty.
What could be the problem?
I would be very grateful for the information. Thanks to all.