Reusing and extending Model and View
Reuses factories while keeping model and UI responsibilities distinct.
Overview
FWLoadModel obtains a source ModelDef object; FWLoadView obtains ViewDef. The model owns business rules/persistence and the view owns presentation. Documentation recommends omitting country suffixes so localization can resolve the correct source. Before extending, verify inactive state, IDs and dependencies. Loading does not mean cloning or establishing a stable extension API for every standard routine. The uninvoked block takes a developer-selected program name. (Sources: refs. 1–3.)
Commented example
#Include "Protheus.ch"
User Function Ed630()
// Source name controlled by the developer, not external input.
Local bModel := {|cProgram| FWLoadModel(cProgram)}
Local bView := {|cProgram| FWLoadView(cProgram)}
ConOut(ValType(bModel)+ValType(bView))
Return NilCreates BB without activation. Each block needs a source with the corresponding factory. Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.
- Keep dialogs out of model rules, document extensions and test release changes.
- 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.