Fields

A field is a unit of data in an entity. It usually represents a column in a database table, but it can model data that is not stored, such as a control or a derived field.

Fields are defined as development objects in either a modeled entity or a component entity.

Fields that represent data stored in a database must be defined as fields in a modeled entity. Modeled fields can be reused in components to create derived fields. Derived fields inherit the properties and script defined in the modeled field, but it is possible to override many properties.

It is also possible to create component fields that are specific to the component and do not reference a modeled field.

Field Data

All fields have properties such as the Name and Data Type. They also have properties that control how data is stored (including the field length), entered, and displayed:

  • Database Interface (Fields)—format in which data is stored in the database, including the data type and field length.
  • Field Syntax—rules for entering data in the field. For example, a date must be entered as DD-MMM-YYYY, or a text string must be all uppercase.
  • Field Layout—display format. For example, you can define a numeric field to display data as euros with 2 decimal places.

To speed development and enforce consistency, you can define these as modeled properties. A modeled property can be referenced in the corresponding field property, making it a derived property. Derived properties inherit the definitions from the modeled property, so if you make a change in a modeled field layout (for example), it is propagated to the derived property the next time the parent entity or component is compiled.

For fields that have a limited set of possible values, you can define a ValRep list or range in the ValRep property. This can hold an associative list of values and their representations (hence the name ValRep), or specify a maximum and minimum value. For more information, see ValRep.

Field Validation

You can script the rules for event processing, such as what to do when a field value is changed, in the triggers belonging to a field.

At runtime, when a user enters or changes data in a field, Uniface checks that the data conforms to what is allowed for the data type of that field, and checks for syntax as defined in a field syntax definition. Fields are automatically validated if the field has been modified or the field has not yet been validated successfully.

Field Presentation

Each field can be associated with a widget that defines the control used to display and edit the data in the user interface. Widgets are component-specific, so they are usually specified in component fields. However, it is also possible to set widget defaults in modeled fields.

Most of the field templates provided by Uniface are distinguished by their widget type.

Related Topics