?
Solved

ISAPI web server project

Posted on 2003-03-28
4
Medium Priority
?
289 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses
Course of the Month15 days, 2 hours left to enroll

770 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