I was wondering the same thing. tiOPF uses RTTI and published
properties.  Cesar did mentioned that he uses is own runtime type
registration/process and not standard RTTI. Not sure what the benefit
of that would be?

The problem is that simple types dont have all necessary information, so I use for use only for Fields, and the BO keed with simples type properties.
All next problems dont exist using this way.

   * how do save a property String = '' ?
         o  EmptyStr or NULL?
* and how about numeric types when zero o save 0 or NULL?
   * With VTF I only need this:
         o if not Object.Member[I].IsNull then

   * if a have a object with 20 properties, do you send all for
     database? I send only the modified, and if no one was modified i
     dont send nothing
         o if Object.Member[I].State.Modified then
   * Notification: when a property is changed, the Field notifies the
     object and object notifies objectlist, so if I call a
     Save(ObjectList) and the ObjectList.State.Modified = False, I know
     that is no object to persist
   * as TValueType implements ISubject, is very easy to link Visual
     Components, I just need to create a object that implements
     observer and Attach
         o FNameView:= TEditView.Create(EditName);
         o Person.Member['Name'].Attach(FNameView);


 TEditView = class(TView, IEditView, IObserver)
 private
   FEdit: TEdit;
   procedure EditChange(Sender: TObject);
   function GetEdit: TEdit;
 protected
procedure Update(const Sender: IInterface; const NotifyType: TNotifyType); override
   function GetEdit: TEdit;
   property Edit: TEdit read GetEdit;
 public
   constructor Create(const Edit: TEdit); reintroduce; virtual;
 end;

{ TEditView }

constructor TEditView.Create(const Edit: TEdit);
begin
 inherited Create(Edit); // pass Edit to inherited Control property
 FEdit:= Edit;
end;

procedure TEditView.EditChange(Sender: TObject);
begin
 (Subject as IStringType).Value:= Edit.Text;
end;

function TEditView.GetEdit: TEdit;
begin
 Result:= FEdit;
end;

procedure TEditView.Update(const Sender: IInterface;
 const NotifyType: TNotifyType); virtual; abstract;
var
 LValue: IStringType;
begin
 inherited;
 if (Sender <> Self) and Supports(Sender, IStringType, LValue) then
 begin
   case NotifyType of
     ntClear:
       Edit.Clear;
     ntDetached:
       begin
         Edit.Clear;
         Edit.OnChange:= EditChange;
       end;
     ntAttached:
       begin
         Edit.Text:= LValue.Value;
         Edit.OnChange:= EditChange;
       end;
     ntLoaded,
     ntChanged:
       Edit.Text:= LValue.Value;
   end;
 end;
end;


_________________________________________________________________
    To unsubscribe: mail [EMAIL PROTECTED] with
               "unsubscribe" as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives

Reply via email to