Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Interposer classes

186 views
Skip to first unread message

Maximiliano Robaina

unread,
Jan 16, 2004, 1:56:55 PM1/16/04
to
Hi,

Where can get information, examples, etc. about Interposer classes?
I need use this in a datasnap server project, for extend provider's and
ClientDataset features.

Thank in advance.
--
Maxi.


Peter Below (TeamB)

unread,
Jan 17, 2004, 6:33:03 AM1/17/04
to
In article <4008...@newsgroups.borland.com>, Maximiliano Robaina wrote:
> Where can get information, examples, etc. about Interposer classes?
> I need use this in a datasnap server project, for extend provider's and
> ClientDataset features.

Interposers are typically used to replace a component you dropped on a
form, datamodule etc. at design-time with some descendent at run-time.
For this you create a class that derives from the design-time class but
use the same class name. This works since the two classes are defined in
different units.

type
TTabsheet = class( ComCtrls.TTabSheet )
private
FColor: TColor;

Procedure SetColor( value: TColor );
Procedure WMEraseBkGnd( var msg: TWMEraseBkGnd );
message WM_ERASEBKGND;
public
Constructor Create( aOwner: TComponent ); override;
property Color: TColor read FColor write SetColor;
end;

TForm1 = class(TForm)
PageControl1: TPageControl;
TabSheet1: TTabSheet;
TabSheet2: TTabSheet;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

In this example the TForm1 class will now use instances of the redefined
TTabsheet class instead of the stock class used by the designer. You can
place the declaration of the new class into a unit of its own, as long as
you place this unit *after* the one containing the original class in the
using units Uses clause.

I consider interposer classes mostly useful for debugging or quickly
testing some modifications. For production use you should create a real
descendent of the class you want to extend (with a new class name),
install it (if it is a component) and use it also at design-time.


--
Peter Below (TeamB)
Use the newsgroup archives :
http://www.mers.com/searchsite.html
http://www.tamaracka.com/search.htm
http://groups.google.com
http://www.prolix.be


Maximiliano Robaina

unread,
Jan 17, 2004, 8:14:27 AM1/17/04
to
Thank's Peter:
Really you explanation is very clear.
I' have other question about this. I need extend the functionality of the
DataSetProvider in a middle tier app server and alter the BeforeGetRecord
and BeforeApplyUpdate events.
This is possible do it with interposer classes?
Is sufficient override this event? How can do it?

Thanks again.
Regards
---
Maxi.


"Peter Below (TeamB)" <10011...@compuXXserve.com> escribió en el mensaje
news:VA.0000a89...@nomail.please...

Peter Below (TeamB)

unread,
Jan 17, 2004, 3:21:42 PM1/17/04
to
In article <40093576$1...@newsgroups.borland.com>, Maximiliano Robaina wrote:
> Really you explanation is very clear.
> I' have other question about this. I need extend the functionality of the
> DataSetProvider in a middle tier app server and alter the BeforeGetRecord
> and BeforeApplyUpdate events.
> This is possible do it with interposer classes?
> Is sufficient override this event? How can do it?

When you extend a class you do not "override an event", you override the
method that fires the event. If you look at the source in providers.pas you
will see that the TCustomProvider base class has a

procedure DoBeforeGetRecords(Count: Integer; Options: Integer;
const CommandText: WideString; var Params, OwnerData: OleVariant);

method (virtual), which does exactly that. There is a DoBeforeApplyUpdate
method as well that fires the BeforeApplyUpdate event. Those are the methods
to override. Do not forget to call the inherited method before or after your
added code.

0 new messages