Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

ISAPI web server project

Posted on 2003-03-28
4
Medium Priority
?
298 Views
Last Modified: 2010-04-04
i have developed a web server ISAPI project ...
how to separate my source to 2 different (or more) unit ...
currently ..when i double click my WebModule ..i created a new WebActionItem..
problem is...i have hundreds of WebActionItem which i hope to separate them to 2 different WebModule or 2 different unit ...is it possible and how ?

thanks
0
Comment
Question by:chongkeng_woon
  • 3
4 Comments
 
LVL 9

Expert Comment

by:mocarts
ID: 8223720
copy&paste :(
but what kind of web app you have? WebBroker or WebSnap?

mo.
0
 

Author Comment

by:chongkeng_woon
ID: 8223774
i click File | New | Other | Web Server Application
and choose ISAPI/NSAPI Dynamic Link Library ..

how to copy and paste ...?

i create a new WebActionItem - Test1

procedure TQuoteModule.QuoteModuleWebActionTest1Action(
  Sender: TObject; Request: TWebRequest; Response: TWebResponse;
  var Handled: Boolean);
var
  PageProducer : TPageProducer;
begin    
 
  PageProducer := TPageProducer.create(nil);
    try
      PageProducer.HTMLFile := 'test1.htm';            PageProducer.OnHTMLTag := Test1OnTag;
      Response.Content := PageProducer.Content;
    finally
      PageProducer.Free ;
    end;
 
end;

procedure TQuoteModule.Test1OnTag(Sender: TObject; Tag: TTag; const TagString: string; TagParams: TStrings; var ReplaceText: string);
begin
  if CompareText(TagString, 'test')=0 then begin
    .............
    ............
  end;
end;

i created many WebActionItem in this web project in a single pas unit ....my source code line is up to 65858 lines !!!!

so, how to separate them into another unit ??

thanks
0
 
LVL 9

Accepted Solution

by:
mocarts earned 2000 total points
ID: 8224584
// example for WebBroker app
// unit with part of your existing actions (not main module, don't autocreate it!)
unit uActionStore;
type
  TwmActionStore = class(TWebModule)
    procedure WebModule1WebActionItem1Action(Sender: TObject;
      Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
    procedure WebModuleCreate(Sender: TObject);
    procedure WebModuleDestroy(Sender: TObject);
  private
    FPP: TPageProducer;
    // onTag event handlers
    procedure Test1OnTag(Sender: TObject; Tag: TTag; const TagString: string;
      TagParams: TStrings; var ReplaceText: string);
  public
    procedure AppendActionsTo(wm: TWebModule);
  end;

implementation

procedure TwmActionStore.AppendActionsTo(wm: TWebModule);
var
  i: integer;
begin
  for i := 0 to Actions.Count -1 do begin
    with wm.Actions.Add do begin
      // Default := True;
      Enabled := Actions[i].Enabled;
      MethodType := Actions[i].MethodType;
      PathInfo := Actions[i].PathInfo;
      OnAction := Actions[i].OnAction;
    end;
  end;
end;

procedure TwmActionStore.Test1OnTag(Sender: TObject; Tag: TTag;
  const TagString: string; TagParams: TStrings; var ReplaceText: string);
begin
 if CompareText(TagString, 'test')=0 then begin
   ReplaceText := '<H1>Test1OnTag processed this page</H1>';
 end;
end;

procedure TwmActionStore.WebModule1WebActionItem1Action(Sender: TObject;
  Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
begin
  FPP.HTMLFile := 'test1.htm';
  FPP.OnHTMLTag := Test1OnTag;
  Response.Content := FPP.Content;
end;

procedure TwmActionStore.WebModuleCreate(Sender: TObject);
begin
  FPP := TPageProducer.Create(nil);
end;

procedure TwmActionStore.WebModuleDestroy(Sender: TObject);
begin
  FPP.Free;
end;
end.
// ------------------------
// main web module which acctually handles all requests
// can contain own actions and appends actions from actionStore
unit uWebModule;

interface

uses
  Windows, Messages, SysUtils, Classes, HTTPApp, uWMAStore;

type
  TwmMain = class(TWebModule)
    procedure WebModuleCreate(Sender: TObject);
    procedure WebModuleDestroy(Sender: TObject);
  private
    FActionStore: TwmActionStore;
  end;

var
  wmMain: TwmMain;

implementation

procedure TwmMain.WebModuleCreate(Sender: TObject);
begin
  FActionStore := TwmActionStore.Create(nil);
  FActionStore.AppendActionsTo(self);
end;

procedure TwmMain.WebModuleDestroy(Sender: TObject);
begin
  FActionStore.Free;
end;
end.

that's the easiest way I figured out for this..
wbr, mo.
0
 
LVL 9

Expert Comment

by:mocarts
ID: 8224596
forgot to say that TwmActionStore.Actions contains one action named WebActionItem1 and with event handler OnAction pointed to WebModule1WebActionItem1Action method
wbr, mo.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses
Course of the Month13 days, 21 hours left to enroll

581 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question