Usina BRAdvPL Guide
Sign in
← All topics
CLASSUnder review

FWFormModel

FWFormModel():New(cID,[bPre],[bPost],bCommit,bCancel)

Centralizes MVC model structure, validation and persistence.

FWFormModelAdvPL
01 · OVERVIEW

Overview

FWFormModel defines submodels, relationships and validations independently of the UI. This entry covers a selected lifecycle, not every method. In the base class, CommitData delegates persistence to the constructor’s bCommit block: the method name does not create persistence automatically. VldData without an ID validates the whole model; validating a submodel does not mark the whole model as validated. Atilio separates model/view using MPFormModel and custom tables; that does not establish constructor equivalence. The fragment assumes oModel is configured and activated, with operation/data supplied by its caller. (Sources: refs. 1–2.)

02 · SYNTAX

Syntax

FWFormModel():New(cID,[bPre],[bPost],bCommit,bCancel)

Parameters

cID
CharacterRequired

Model ID; do not repeat the main User Function name.

bPre
BlockOptional

Prevalidation returning logical.

bPost
BlockOptional

Postvalidation returning logical.

bCommit
BlockRequired

Persistence implementation.

bCancel
BlockRequired

Cancellation implementation.

Methods

ActivateActivates after definition is complete.oModel:Activate([lCopy])
VldDataWithout ID, validates the whole model.oModel:VldData([cIDModel],[lVldOwner]) -> lRet
Return value

Logical.

CommitDataRequires a valid model and delegates to persistence block.oModel:CommitData() -> lRet
Return value

Logical.

03 · PRACTICAL EXAMPLE

Commented example

// Fragment: oModel is configured/active, with defined persistence.
Local lSaved := .F.
// Validate the whole model before requesting persistence.
If oModel:VldData()
    lSaved := oModel:CommitData()
EndIf
// Handle model errors; do not end a caller-owned transaction here.
Expected result

Requests persistence only after full validation succeeds. Does not establish commit of an external transaction. Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.

BEST PRACTICES
  • Complete definitions before Activate and release resources according to lifecycle. The model must not depend on Alert/MsgAlert. New has an inconsistent return label in TDN; its examples use it to obtain the object. The legacy entry had no recorded creation date. The displayed date identifies creation of this editorial-model version, without reconstructing the old page date.
  • Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.

Related content

REFERENCES
  1. TOTVS. FWFormModel. New, Activate, VldData e CommitData. Accessed on 2026-10-28.
  2. Atilio. dan-atilio/AdvPL. Exemplos/Vídeo Aulas/018 - Modelo 1 em MVC/zModel1.prw. Arquivo completo analisado; adaptação editorial. Accessed on 2026-10-28.
Status
Under review
Page created on
Last reviewed on
Original language
Portuguese
Reviewed by
Usina.BR

Was this content helpful?

👍 Like 0👎 Dislike 0

Sign in to rate this article.

0 approved comment(s)

Comments

There are no approved comments yet.

Sign in with Google or Microsoft to comment.

Powered by Usina Docs · Alpha