Declarative Creation of Data Components

The simplest way to create data components for a screen is to define them in the screen XML descriptor in the <data> element.

Let’s consider the data model consisting of Customer, Order and OrderLine entities. The edit screen for the Order entity can have the following XML definition:

    <instance id="orderDc" class="com.company.sales.entity.Order" view="order-edit">

        <collection id="linesDc" property="lines"/>

    <collection id="customersDc" class="com.company.sales.entity.Customer" view="_minimal">
            <query><![CDATA[select e from sales_Customer e]]></query>

In this case, the following data components are created:

  • DataContext instance.

  • InstanceContainer with orderDc id and InstanceLoader for the Order entity.

  • CollectionPropertyContainer with linesDc id for the OrderLines entity. It is bound to the Order.lines collection attribute.

  • CollectionContainer with customersDc id for the Customer entity. It is loaded by CollectionLoader using the specified query.

The data containers can be used in visual components as follows:

    <dateField dataContainer="orderDc" property="date"/> (1)
    <form id="form" dataContainer="orderDc"> (2)
            <textField property="amount"/>
            <lookupPickerField id="customerField" property="customer"
                               optionsContainer="customersDc"/> (3)
    <table dataContainer="linesDc"> (4)
            <column id="product"/>
            <column id="quantity"/>
1 Standalone fields have dataContainer and property attributes.
2 form propagates dataContainer to its fields so they need only property attribute.
3 Lookup fields have optionsContainer attribute.
4 Tables have only dataContainer attribute.