Usina BRAdvPL Guide
Sign in
← All topics
PRACTICAL GUIDEUnder review

Reusing and extending Model and View

Reuses factories while keeping model and UI responsibilities distinct.

Reusing and extending Model and ViewAdvPL
01 · OVERVIEW

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.)

03 · PRACTICAL EXAMPLE

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 Nil
Expected result

Creates 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.

BEST PRACTICES
  • 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.

Related content

REFERENCES
  1. TOTVS. FWLoadModel. Accessed on 2026-10-27.
  2. TOTVS. FWLoadView. Accessed on 2026-10-27.
  3. TOTVS. FWFormModel. Seções SetRelation, SetPrimaryKey, SetOperation, VldData, CommitData e GetErrorMessage. Accessed on 2026-10-27.
Status
Under review
Page created on
Last reviewed on
Original language
Portuguese
Reviewed by
Usina.BR
0 approved comment(s)

Comments

There are no approved comments yet.

Sign in with Google or Microsoft to comment.

Powered by Usina Docs · Alpha