home_dm.pas
上传用户:fh681027
上传日期:2022-07-23
资源大小:1959k
文件大小:1k
源码类别:

Delphi控件源码

开发平台:

Delphi

  1. unit home_dm;
  2. interface
  3. uses
  4.   Windows, Messages, SysUtils, Classes, HTTPApp, WebModu, HTTPProd, ReqMulti,
  5.   WebDisp, WebAdapt, WebComp;
  6. type
  7.   Thome = class(TWebAppPageModule)
  8.     PageProducer: TPageProducer;
  9.     WebAppComponents: TWebAppComponents;
  10.     ApplicationAdapter: TApplicationAdapter;
  11.     PageDispatcher: TPageDispatcher;
  12.     AdapterDispatcher: TAdapterDispatcher;
  13.     Count: TAdapterField;
  14.     procedure PageDispatcherBeforeDispatchPage(Sender: TObject;
  15.       const PageName: String; var Handled: Boolean);
  16.     procedure CountGetValue(Sender: TObject; var Value: Variant);
  17.   private
  18.     HitCount: Integer;
  19.   public
  20.     { Public declarations }
  21.   end;
  22.   function home: Thome;
  23. implementation
  24. {$R *.dfm}  {*.html}
  25. uses WebReq, WebCntxt, WebFact, Variants;
  26. function home: Thome;
  27. begin
  28.   Result := Thome(WebContext.FindModuleClass(Thome));
  29. end;
  30. procedure Thome.PageDispatcherBeforeDispatchPage(Sender: TObject;
  31.   const PageName: String; var Handled: Boolean);
  32. begin
  33.   Inc (HitCount);
  34. end;
  35. procedure Thome.CountGetValue(Sender: TObject; var Value: Variant);
  36. begin
  37.   Value := HitCount;
  38. end;
  39. initialization
  40.   if WebRequestHandler <> nil then
  41.     WebRequestHandler.AddWebModuleFactory(TWebAppPageModuleFactory.Create(Thome, TWebPageInfo.Create([wpPublished {, wpLoginRequired}], '.html'), caCache));
  42. end.