Skip to content

TBaseMediator

Base class for mediating data between model and view objects

Declaration

Source position: fpobserver.pp line 58

type

  TBaseMediator = class(TComponent, IFPObserver)
  public
    destructor Destroy;
    procedure ObjectToView;
    procedure ViewToObject;
    class function ViewClass : TClass;
    class function CompositeMediator : Boolean;
    property Subject: TObject; {rw}
    property View: TObject; {r}
    property Valuelist: TObjectList; {rw}
  published
    property SubjectPropertyName: string; {rw}
    property Active: Boolean; {rw}
    property ReadOnly: Boolean; {rw}
    property OnViewToObject: TMediatingEvent; {rw}
    property OnObjectToView: TMediatingEvent; {rw}
  end;

Description

The TBaseMediator class provides automatic data binding between model objects (subjects) and view components. It implements the observer pattern to automatically synchronize data when either the model or view changes.

The mediator supports bidirectional data binding, read-only modes, and custom data transfer events. Subjects must implement the IFPObserved interface, while views must have published properties that can be accessed by name.

This class serves as the base class for more specialized mediators like list mediators and component mediators, providing common functionality for property validation, observer management, and data transfer coordination.

Properties

Member Visibility Description
Active published Enables or disables automatic data synchronization
ReadOnly published Prevents data transfer from view to subject when True
Subject public Model object implementing IFPObserved interface
SubjectPropertyName published Name of property in subject object to mediate
Valuelist public Optional list of values for list-based mediators
View read only public View component for data display and editing
See all Properties

Methods

Member Visibility Description
CompositeMediator public Indicates whether this is a composite mediator
Destroy public Destroys the mediator and cleans up observer attachments
ObjectToView public Copies data from subject object to view component
ViewClass public Returns the minimum view class this mediator can handle
ViewToObject public Copies data from view component to subject object
See all Methods

Events

Member Visibility Description
OnObjectToView published Event triggered when copying data from subject to view
OnViewToObject published Event triggered when copying data from view to subject
See all Events

See also

Name Description
TObservedHook Observer pattern helper class implementing IFPObserved interface
TComponentMediator General-purpose mediator for any TComponent-based view