Marco Web Center

[an error occurred while processing this directive]

Home: Code Repository: Mastering Delphi 6

Chapter 22 - Project WSnapUsers

Project Structure

WSnapUsers.dpr
program WSnapUsers;

{$APPTYPE GUI}

uses
  Forms,
  ComApp,
  MainForm in 'MainForm.pas' {Form1},
  Home_dm in 'Home_dm.pas' {Home: TWebAppPageModule} {*.html},
  Login_dm in 'Login_dm.pas' {loginform: TWebPageModule} {*.html};

{$R *.RES}

begin
  Application.Initialize;
  Application.CreateForm(TForm1, Form1);
  Application.Run;
end.
MainForm.pas
unit MainForm;

interface

uses
  SysUtils, Classes, Graphics, Controls, Forms, Dialogs;

type
  TForm1 = class(TForm)
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

uses ComApp;

{$R *.DFM}

const
  CLASS_ComWebApp: TGUID = '{069C0526-AAB6-4567-978A-210B961F9139}';

initialization
  TWebAppAutoObjectFactory.Create(Class_ComWebApp,
    'WSnapUsers', 'WSnapUsers Object');

end.
Home_dm.pas

unit Home_dm;

interface

uses
  Windows, Messages, SysUtils, Classes, HTTPApp, WebModu, HTTPProd, ReqMulti,
  WebDisp, WebAdapt, WebComp, WebSess, WebUsers;

type
  THome = class(TWebAppPageModule)
    PageProducer: TPageProducer;
    WebAppComponents: TWebAppComponents;
    ApplicationAdapter: TApplicationAdapter;
    PageDispatcher: TPageDispatcher;
    AdapterDispatcher: TAdapterDispatcher;
    WebUserList1: TWebUserList;
    EndUserSessionAdapter1: TEndUserSessionAdapter;
    SessionsService1: TSessionsService;
    AdapterField: TAdapterField;
  private
    { Private declarations }
  public
    { Public declarations }
  end;

  function Home: THome;

implementation

{$R *.dfm}  {*.html}

uses WebReq, WebCntxt, WebFact, Variants;

function Home: THome;
begin
  Result := THome(WebContext.FindModuleClass(THome));
end;

initialization
  if WebRequestHandler <> nil then
    WebRequestHandler.AddWebModuleFactory(TWebAppPageModuleFactory.Create(THome, TWebPageInfo.Create([wpPublished, wpLoginRequired], '.html'), caCache));

end.
Login_dm.pas

unit Login_dm;

interface

uses
  Windows, Messages, SysUtils, Classes, HTTPApp, WebModu, HTTPProd,
  WebAdapt, WebComp, CompProd, PagItems, SiteProd, WebForm, MidItems;

type
  Tloginform = class(TWebPageModule)
    AdapterPageProducer: TAdapterPageProducer;
    LoginFormAdapter1: TLoginFormAdapter;
    AdapterForm1: TAdapterForm;
    AdapterFieldGroup1: TAdapterFieldGroup;
    AdapterCommandGroup1: TAdapterCommandGroup;
  private
    { Private declarations }
  public
    { Public declarations }
  end;

  function loginform: Tloginform;

implementation

{$R *.dfm}  {*.html}

uses WebReq, WebCntxt, WebFact, Variants;

function loginform: Tloginform;
begin
  Result := Tloginform(WebContext.FindModuleClass(Tloginform));
end;

initialization
  if WebRequestHandler <> nil then
    WebRequestHandler.AddWebModuleFactory(TWebPageModuleFactory.Create(Tloginform, TWebPageInfo.Create([{wpPublished , wpLoginRequired}], '.html'), crOnDemand, caCache));

end.
MainForm.dfm
object Form1: TForm1
  Left = 236
  Top = 107
  Width = 211
  Height = 126
  Caption = 'WSnapUsers'
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = False
  PixelsPerInch = 96
  TextHeight = 13
end
Home_dm.dfm
object Home: THome
  OldCreateOrder = False
  PageProducer = PageProducer
  AppServices = WebAppComponents
  Left = 254
  Top = 107
  Height = 296
  Width = 215
  object PageProducer: TPageProducer
    ScriptEngine = 'JScript'
    Left = 48
    Top = 8
  end
  object WebAppComponents: TWebAppComponents
    Sessions = SessionsService1
    PageDispatcher = PageDispatcher
    AdapterDispatcher = AdapterDispatcher
    ApplicationAdapter = ApplicationAdapter
    EndUserAdapter = EndUserSessionAdapter1
    UserListService = WebUserList1
    Left = 48
    Top = 56
  end
  object ApplicationAdapter: TApplicationAdapter
    ApplicationTitle = 'WSnapUsers'
    Left = 48
    Top = 104
    object TAdapterDefaultActions
    end
    object TAdapterDefaultFields
    end
  end
  object PageDispatcher: TPageDispatcher
    Left = 48
    Top = 152
  end
  object AdapterDispatcher: TAdapterDispatcher
    Left = 48
    Top = 200
  end
  object WebUserList1: TWebUserList
    UserItems = <
      item
        UserName = 'Marco'
        Password = 'm'
      end>
    Left = 120
    Top = 8
  end
  object EndUserSessionAdapter1: TEndUserSessionAdapter
    LoginPage = 'loginform'
    Left = 120
    Top = 56
    object TAdapterDefaultActions
    end
    object TAdapterDefaultFields
      object AdapterField: TAdapterField
      end
    end
  end
  object SessionsService1: TSessionsService
    Left = 120
    Top = 112
  end
end
Login_dm.dfm
object loginform: Tloginform
  OldCreateOrder = False
  PageProducer = AdapterPageProducer
  Left = 479
  Top = 148
  Height = 150
  Width = 215
  object AdapterPageProducer: TAdapterPageProducer
    HTMLDoc.Strings = (
      '<html>'
      '<head>'
      '</head>'
      '<body>'
      '<#STYLES><#WARNINGS><#SERVERSCRIPT>'
      '</body>'
      '</html>')
    Left = 48
    Top = 8
    object AdapterForm1: TAdapterForm
      object AdapterFieldGroup1: TAdapterFieldGroup
        Adapter = LoginFormAdapter1
      end
      object AdapterCommandGroup1: TAdapterCommandGroup
        DisplayComponent = AdapterFieldGroup1
        Custom = 'align=center'
      end
    end
  end
  object LoginFormAdapter1: TLoginFormAdapter
    Left = 48
    Top = 56
    object TAdapterDefaultActions
    end
    object TAdapterDefaultFields
    end
  end
end