How To Create A Datadescriptor Programmatically

DataDescriptors can be created not only by using XML files but also by implementing them in source code (dynamic DataDescriptor ). It is also possible to programmatically modify DataDescriptors created using XML files: this way only the DataDescriptor instance retrieved from the framework will be modified. If a DataDescriptor is retrieved more than once, the framework will return its original (not modified) instance. Use this method if you would like to modify a DataDescriptor only once.

To create a DataDescriptor , you need to create a DataDescriptor entity. The DataDescriptor class contains all the methods necessary to set up a DataDescriptor entity. Once the entity is created, you can add DataDescriptorColumn entities to a DataDescriptor entity. If you are done with configuring a DataDescriptor , you are ready to use it in the framework. A programmatically created DataDescriptor has similar behavior to one created from an XML file.

Example for a dynamically created DataDescriptor. All logged-in users may use the DataDescriptor, but only those with PRODUCT_MANAGER access are allowed to write data:

If you take a look at the above source code, you may observe that there are column names with a period (.) This means a many-to-one relation in the database entity. In other words, each Product record is related to a Supplier record (with Product and Supplier being two different database tables).

When displayed in a list, no suppliers appear, but instead, the list contains categories such as supplier’s country and supplier’s city. If the DataDescriptor is displayed on an editor interface, none of these columns are visible but a combo-box containing all available suppliers.

The DataDescriptor uses the following entity:

There is a many-to-one relation in the entity class, connecting a Product record with a Supplier record: