ISAPI web server project

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
chongkeng_woonAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mocartsCommented:
copy&paste :(
but what kind of web app you have? WebBroker or WebSnap?

mo.
0
chongkeng_woonAuthor Commented:
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
mocartsCommented:
// 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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mocartsCommented:
forgot to say that TwmActionStore.Actions contains one action named WebActionItem1 and with event handler OnAction pointed to WebModule1WebActionItem1Action method
wbr, mo.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.