MVC (Model View Controller)
ModelDef -> Model; ViewDef -> View; MenuDef -> actionsSeparates data rules, UI and application actions.
Overview
ModelDef defines the model and its rules; ViewDef binds fields and grids to it; MenuDef supplies actions and operations. MPFormModel supports the Protheus pattern with Help handling, memory variables and default persistence. UI code should not own rules also required by automatic execution. Definition, activation, validation, persistence and cancellation are distinct steps. The community single-entity sample separates these functions; the table below summarizes responsibilities without opening tables or windows. (Sources: refs. 1–4.)
Syntax
ModelDef -> Model; ViewDef -> View; MenuDef -> actionsCommented example
#Include "Protheus.ch"
User Function Ed552()
Local aLayers := {{"ModelDef","Rules and data"},{"ViewDef","UI"},{"MenuDef","Actions"}}
Local nI
// Responsibility map; no MVC routine is activated.
For nI := 1 To Len(aLayers)
ConOut(aLayers[nI,1]+" -> "+aLayers[nI,2])
Next
Return NilPrints three responsibility rows. Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.
- Keep model/view IDs consistent, separate validation from persistence and review action permissions. For User Function entry points, follow the official model-ID naming rule rather than reusing the function name blindly.
- Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.

Comments
There are no approved comments yet.
Sign in with Google or Microsoft to comment.