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

Delphi控件源码

开发平台:

Delphi

  1. unit countries_dm;
  2. interface
  3. uses
  4.   Windows, Messages, SysUtils, Classes, HTTPApp, WebModu, HTTPProd,
  5.   DBTables, DB, DBWeb;
  6. type
  7.   Tcountries = class(TWebPageModule)
  8.     DataSetTableProducer1: TDataSetTableProducer;
  9.     Table1: TTable;
  10.     Session1: TSession;
  11.     PageProducer: TPageProducer;
  12.     procedure WebPageModuleBeforeDispatchPage(Sender: TObject;
  13.       const PageName: String; var Handled: Boolean);
  14.     procedure PageProducerHTMLTag(Sender: TObject; Tag: TTag;
  15.       const TagString: String; TagParams: TStrings;
  16.       var ReplaceText: String);
  17.   private
  18.     { Private declarations }
  19.   public
  20.     { Public declarations }
  21.   end;
  22.   function countries: Tcountries;
  23. implementation
  24. {$R *.dfm}  {*.html}
  25. uses WebReq, WebCntxt, WebFact, Variants, country_dm;
  26. function countries: Tcountries;
  27. begin
  28.   Result := Tcountries(WebContext.FindModuleClass(Tcountries));
  29. end;
  30. procedure Tcountries.WebPageModuleBeforeDispatchPage(Sender: TObject;
  31.   const PageName: String; var Handled: Boolean);
  32. begin
  33.   Table1.Open;
  34.   Table1.First;
  35. end;
  36. procedure Tcountries.PageProducerHTMLTag(Sender: TObject; Tag: TTag;
  37.   const TagString: String; TagParams: TStrings; var ReplaceText: String);
  38. begin
  39.   if TagString = 'htmltable' then
  40.     ReplaceText := DataSetTableProducer1.Content;
  41. end;
  42. initialization
  43.   if WebRequestHandler <> nil then
  44.     WebRequestHandler.AddWebModuleFactory(TWebPageModuleFactory.Create(Tcountries, TWebPageInfo.Create([wpPublished {, wpLoginRequired}], '.html'), crOnDemand, caCache));
  45. end.