Data Binding¶
Entry_Item binds data-aware controls and columns to Data Dictionary fields. Legacy code often used global table-buffer field names like Customer.Name; TechStack code binds through the Data Dictionary object that owns the local buffer, such as oCustomerDD.Name or oCustomer_DD.Name. Entities define the fields, while Data Dictionaries own the local record buffer used by the UI.
See the DEO Binding API reference for binding and server protocol members.
Before: global table buffer binding¶
WebOrder-style code can define a Data Dictionary object and set it as Main_DD and Server, while Entry_Item still names the global Table.Field buffer.
Object oCustomerDataDictionary is a cCustomerDataDictionary
End_Object
Set Main_DD to oCustomerDataDictionary
Set Server to oCustomerDataDictionary
Object oCustomerName is a cWebForm
Entry_Item Customer.Name
Set psLabel to "Name:"
End_Object
Customer.Name names the global Customer table buffer; it does not name the oCustomerDataDictionary object.
Now: local Data Dictionary object binding¶
TechStack binding names the Data Dictionary object before the dot. The object owns the local buffer used by the control or column.
Object oCustomerDD is a cCustomerDataDictionary
End_Object
Set Main_DD to oCustomerDD
Set Server to oCustomerDD
Object oCustomerName is a cWebForm
Entry_Item oCustomerDD.Name
Set psLabel to "Name:"
End_Object
oCustomerDD and oCustomer_DD are ordinary object names; the important part is that the prefix is the Data Dictionary object, not the table name.
Object oRoomDD is a cRoomDataDictionary
End_Object
Set Main_DD to oRoomDD
Set Server to oRoomDD
Object oRoomDD_Name is a cWebForm
Set psLabel to "Name"
Entry_Item oRoomDD.Name
End_Object
This is the same binding shape as oCustomerDD.Name: oRoomDD is the Data Dictionary object and Name is the field.
Migration pattern¶
| Legacy binding | TechStack binding |
|---|---|
Entry_Item Customer.Name |
Entry_Item oCustomerDD.Name |
Entry_Item Customer.Customer_Number |
Entry_Item oCustomerDD.Customer_Number |
Entry_Item OrderHeader.Order_Number |
Entry_Item oOrderHeaderDD.Order_Number |
Entry_Item OrderDetail.Price |
Entry_Item oOrderDetailDD.Price |
- Keep the field suffix after the dot.
- Replace the table name before the dot with the DD object name that owns that table's local buffer.
- If the local object uses another naming style, use that exact object name, e.g.
oCustomer_DD.Name.
Related Data Dictionaries¶
For parent or related fields, connect related Data Dictionary objects with Set DDO_Server, then bind each field through the Data Dictionary object that owns that local buffer.
Object oRoom_DD is a cRoomDataDictionary
End_Object
Object oPresenter_DD is a cPresenterDataDictionary
End_Object
Object oPresentation_DD is a cPresentationDataDictionary
Set DDO_Server to oRoom_DD
Set DDO_Server to oPresenter_DD
End_Object
Set Main_DD to oPresentation_DD
Set Server to oPresentation_DD
Entry_Item oPresentation_DD.Title
Entry_Item oRoom_DD.Name
Entry_Item oPresenter_DD.FirstName
The prefix before the dot chooses the local buffer owner; it is not a global table selector.
Calculated and back-end values¶
Binding is not limited to stored fields. A bound value can also be computed by the storage back end and returned alongside stored fields.
cDbQuery.Bind_Native_Expression adds a back-end-specific expression as an extra column in an ad hoc query result, next to the fields added with Entry_Item. The expression string is passed to the back end, so its syntax is back-end specific (the example below uses SQLite string concatenation).
Object oCustomerQuery is a cDbQuery
Set Server to oCustomer_DD
Entry_Item oCustomer_DD.Name
Send Bind_Native_Expression "Name || ', ' || City" (RefTable(oCustomer_DD.Name))
End_Object
Variant[][] aRows
DbRowId[] aRowIds
Get FetchFirst of oCustomerQuery 25 (&aRowIds) to aRows
The native expression is returned as one of the query's paFields columns. See the cDbQuery reference and Bind_Native_Expression for the full query API.
On the control side, OnSetCalculatedValue (on cBaseDEO_Mixin) lets a data-entry object adjust a calculated display value before it is used.
Where this is heading: back-end-specific data binding is expanding toward binding calculated values through native expressions more broadly, and toward back-end-specific filtering at the constraint level. In the client/server WebApp model the intent is for business rules to be validated on the client and always revalidated on the server. These are planned directions; today, native-expression query columns and the calculated-value hook above are the supported pieces.
Checklist¶
- Find the
Object ... is a c...DataDictionarythat owns the field's table. - Make sure the view, group, list, or column container uses the correct
Set ServerorSet Main_DDfor the binding context. - Replace
Entry_Item Table.FieldwithEntry_Item DataDictionaryObject.Field. - Keep the field name after the dot unchanged unless the field itself was renamed.
- For related fields, bind through the related DD object and connect the relationship with
Set DDO_Server.