Data Components

Data components are non-visual elements of views that provide loading of data, binding it to data-aware visual components and saving changed data back to the data store.

  • Containers provide the thin layer between entities and data-aware visual components. Different types of containers hold either single instances or collections of entities.

  • Loaders load data to containers.

  • DataContext tracks changes in entities and saves changed instances upon request.

Usually, data components are defined in the view XML descriptor in the <data> element:

<data readOnly="true">
    <collection id="departmentsDc"
        <fetchPlan extends="_base">
            <property name="hrManager" fetchPlan="_base"/>
        <loader id="departmentsDl">
                <![CDATA[select e from Department e]]>

Data components can be injected into the controller in the same way as visual components:

private CollectionContainer<Department> departmentsDc;

Data components of a particular view are registered in the ViewData object which is associated with the controller and available through its getViewData() method. This object is useful when you need to load all data for the view, for example:

public void onReady(final ReadyEvent event) {
Use DataLoadCoordinator facet for declarative linking of data loaders to data containers, visual components and view events.