Generic and Bound Entities and Fields

A modeled component usually contains generic entities and fields that act as placeholders for entities and fields in the derived component. An object is generic when its Is Generic property set to True.

When you create a derived component from the modeled component, the generic entities and fields are copied as bound entities and fields. Bound entities and fields have their Is Bound property set to True, and their Bound To property specifies the corresponding generic object.

Initially, the names of bound objects are the same as their generic counterparts. To have the derived component use real data, you need to rename these objects to modeled objects.

When you rename a bound entity to a modeled entity, the bound entity inherits from the modeled entity. However, the binding to the modeled component ensures that any component-level properties, constants, and ProcScript modules that were copied from the generic entity are inherited. For more information, see Inheritance from Modeled Components .

When you compile the derived component, all references to the generic entities and fields in modeled ProcScript are resolved to use the actual entity and field names in the derived component.

This is also true for bound elements in the HTML layouts of modeled dynamic and static server page components. In these components, elements in the layout are bound to entities and fields in the data structure using the entity or field name. During compilation of derived components, For more information, see Binding Web Layout to Component Structure.

Referencing Generic Objects in ProcScript

In the modeled component, you can write code that manipulates generic entity and field names by referencing them as constants. For example, MYENTITY.GENERIC can be referenced in ProcScript as <MYENTITY> or <MYENITY.GENERIC> (note the angle brackets).

operation exec ; in modeled component
  retrieve/e <MYENTITY>
  edit
  return 0
end

When the derived component is compiled, these references are resolved to the names of the bound entities and fields.

During compilation, Uniface uses the value of Bound To property to define implicit compile-time constants and map them to the actual object names. For example, if a bound entity is renamed to COUNTRY.ORG and its Bound To property specifies the entity MYENTITY.GENERIC, Uniface defines the following implicit constant mappings:

#define MYENTITY.GENERIC = COUNTRY.ORG
#define MYENTITY = COUNTRY.ORG

You can refer to generic objects using the following constants:

Constants for Generic Entities and Fields
Constant Description Example Constant Example Value
<MODELEDCOMPONENTNAME> Name of the modeled component (defined in Uniface 10) <MODELEDCOMPONENTNAME> MY_MDL_CPT
<TEMPLATENAME> Name of the modeled component (migrated from Uniface 9) <TEMPLATENAME>

MY_CPT_TPL

<EntityName>   <MYENTITY> MYENTITY.GENERIC
<EntityName.ModelName> Fully-qualified name of the generic entity <MYENTITY.GENERIC> MYENTITY.GENERIC
<FieldName.EntityName.ModelName> Fully-qualified name of the generic field <FLD1.<MYENTITY>> FLD1.MYENTITY.GENERIC
<UNQ_EntityName> Unique name of the generic entity <UNQ_MYENTITY> MYENTITY
<UNQ_FieldName.EntityName.ModelName> Unique name of the generic field <UNQ_FLD1.<MYENTITY>> FLD1
<GlobalConstantName> Global constant <OK> 1
<ComponentConstantName> Component constant <ERROR> 12345

Renaming Bound Objects

Assume that modeled component is created for displaying lists that include a name and an image. the component contains a generic entity called MYENTITY.GENERIC which contains two generic fields, ID and IMAGE. The exec operation contains the statement retrieve/e <MYENTITY>.

By using this modeled component to create two new components, you ensure that the coded behavior is the same for both derived components. All that you need to do is rename the MYENTITY.GENERIC entity and its fields to the desired modeled entities. For example:

  Modeled Component Derived Component 1 Derived Component 2
Component Name: MDLC_LIST1 CPT_L_COUNTRY CPT_L_EMPLOYEE
Entity Name: MYENTITY.GENERIC COUNTRY.ORG

PERSON.ORG

Field Name 1: ID CTRY_CODE FULL_NAME
Field Name 2: IMAGE FLAG PHOTO
Runtime behavior: Not applicable

Retrieves the country codes and flags of COUNTRY.ORG

Retrieves the names and photos of PERSON.ORG

Related Topics