The Tersus Common Library contains several basic data types.
Most modeling is made using these types, which may also be used to construct composite data types.
Sometimes it is useful to restrict the allowed content for data elements (their "valid values"). This can be achieved by explicit modeling (modeling a validation process that checks whether an element's value matches the constraints). Alternatively, a special data type may be defined specifying the constraints on its valid values.
In the Table Wizard, the user can select for a field one of five basic data types (Text, Number, Data, Date and Time, or Boolean). Then the user may specify the valid values of a field in one of 4 ways:
When the user specifies valid values for a field, the Table Wizard creates a new data model (a user defined Data Type). The user defined data type has the same plug-in and icon as the basic data type from which it is derived. In addition, it has a validValues shared property holding the valid values specifications provided by the user.
When the valid values are specified by either a foreign key or a list of values, the Table Wizard automatically creates a Chooser field using the user defined data type. When displayed on screen, the Chooser is represented by a drop-down list that lets the user choose one of the possible values for the field.
A user defined data type can be used in modeling wherever a basic data type is used. There can also be many Chooser elements using any user defined data type, and for each of them there is a need to initialize the possible values from which the user may choose (the <Options> element of the Chooser).
To improve performance, especially when the valid values are specified by a foreign key (and therefore require database access to read all possible values), it is best to have a single initialization process in each view to get the possible values for all user defined data types used in the view.
The Table Wizard achieves this by creating a global valid values data structure. It is a model named <Valid Values> in the root package of the application, and it contains a repetitive data element for each user defined data type created by the Table Wizard anywhere is the application (actually, only those for which the valid values are specified by either a foreign key or a list of values). Each view contains a <Valid Values> data element and an early initialization process <Init> that initializes the list of possible values for all user defined data types used in the view.
Here is a screenshot of the top right part of a view model with an early initialization process (taken from Stage 7 of the Shopping List Tutorial):
Note that since the above initialization happens only once, when the view is first activated. Therefore, any subsequent update to the database will not be reflected in <Valid Values>. If such updates are expected, a refresh process is required. See an example of such a refresh process in the SQL Examples project ("SQL Examples/View/Employees/Table/Action Header Group/New/Save/Refresh Employee List").
The Table Wizard also creates an early initialization process <Init> in each Chooser it creates for user define data types. The <Init> of a Chooser is very efficient - it simply copies the values from the relevant element in the view's <Valid Values> to the <Options> element of the Chooser.
Here is a screenshot of an early initialization process of a chooser:
To Do: Table Wizard to create validation processes to set the <Validation Message> of fields not containing valid values.
When importing an XML Schema definition file (.xsd file), definitions of elements and attributes are imported as data models (Data Types).
For more details, refer to the technical documentation on XML Schema and WSDL Support in Tersus.
To Do: Improve XSD import to use th valid values mechanism.
For best results, use the Firefox browser..