Skip to content
Carlo Barazzetta edited this page Dec 4, 2018 · 6 revisions

Primer Demo: Exposing Objects

Making objects available in the user interface of an application throughdata-aware controls is known as  exposing objects. InstantObjects allowsyou to expose any object with published properties.

TInstantExposer is the component to use when an object or part of an object that is already present in memory needs to be exposed. TInstantExposer is a TDataSet descendant, which means it can be attached to data-aware controls via a TDataSource. When an object is assigned to the Subject property of a TInstantExposer component, the object or the objects contained in the object are represented as rows in the dataset.The published properties of the exposed object(s) are represented as columns in the dataset.

The contact book demonstrates how exposers can be used to show and edit business objects in the user interface. TBasicEditForm is the base for all forms used by the application to edit objects. This form contains anexposer which is connected through a TDataSource to data-aware controls introduced in descending forms designed for editing objects of specific classes. When an object needs to be edited, it is passed to the exposer in a suitable edit form.

When exposing business objects, relations to other objects defined in the business model are recognized and handled automatically. One-to-many relations are represented as nested datasets within the exposer. In addition, exposers can be linked in a master-detail fashion allowing any related object to be exposed via the referring object. The exposers PhonesExposer on the form TContactEditForm and Emails Exposer on the form TPersonEditForm are examples of detail exposers that are linked to a master exposer.

If you study TBasicEditForm and the various descendants hereof you will notice that they contain no code for handling the editing of the object: this is done automatically by the exposer.

Clone this wiki locally