unit Tshowme; {

Custom TWebApp objects and Session Vars

For best results, please download this file to your local machine and view it with an editor.

Here is some sample code, meant to be simpler than the fish store, to help you see what you need to do to make a custom app object and a VARS layer for the TWebSession...

Replace 'showMe' with the phrase of your choice.

}


{ Author: Ann Lynnworth
  Sample code to show how to make a custom app object with
  a couple of custom variables...
}
{ Our License Agreement for FREE items is posted on the web.
  Please Read It Now.
  If you agree to be bound to all its terms you may use our software,
  otherwise you may not.
}

{-------------------------------------------------------------------------------}

interface

uses
  SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics
  , Controls
  , WebTypes
  , WebApp, WebVars
  ;

type
  TShowMeSessionVars = class(TWebSessionVars)
  private
    fOrderTotal : double;
    fFramesOk : boolean;
    fAList : TStringList;
  protected
    function  getAList : TStringList;
    procedure setAList( value : TStringList );
  public
    Constructor Create(aWebSession:TWebSession); override;
    Destructor Destroy; override;
  published
    property OrderTotal : double read fOrderTotal write fOrderTotal stored false;
    property FramesOk : boolean read fFramesOk write fFramesOk stored false;
    property AList : TStringList read getAList write setAList stored false;
  end;

  TShowMeSession = class(TWebSession)
  protected
    function VarsClass:TWebSessionVarsClass; override;
    end;

type
  TShowMeApp = class(TWebApp)
  private
    fLogo : string;
  protected
    function SessionClass:TWebSessionClass; override;
  public
    constructor Create(AOwner: TComponent); override;
    destructor  Destroy; override;
  published
    property Logo:string read fLogo write fLogo stored false;
  end;

procedure Register;

implementation

{----------------------------------------------------------------------------------------}

Constructor TShowMeApp.Create(aOwner:tComponent);
begin
  inherited Create(aOwner);
  {placeholder in case you need to do something else later}
end;

Destructor TShowMeApp.Destroy;
begin
  inherited Destroy;
  {placeholder}
end;

function TShowMeApp.SessionClass:TWebSessionClass;
begin
  Result:= TShowMeSession;
end;

function TShowMeSession.VarsClass:TWebSessionVarsClass;
begin
  Result:= TShowMeSessionVars;
end;

{-------------------------------------------------------------------------------}

Constructor TShowMeSessionVars.Create(aWebSession:TWebSession);
begin
  inherited Create(aWebSession);
  fAList:=TStringList.create;
end;

Destructor TShowMeSessionVars.Destroy;
begin
  fAList.free;
  inherited Destroy;
end;

{-------------------------------------------------------------------------------}

function TShowMeSessionVars.GetAList:TStringList;
begin
  result:=fAList;
end;

procedure TShowMeSessionVars.SetAList(value:TStringList);
begin
  fAList.assign(value);
end;

{-------------------------------------------------------------------------------}

procedure Register;
begin
  RegisterComponents('WebApps', [TShowMeApp, TShowMeSession]);
end;

end.


{ 
}