Browse Source

* Added TWebController.onGetURL property
* Made TWebPage.Module public
* Fixed handling ajax-calls of components within containers
* THtmlContentProducer.GetIdentification added
* Ability to reset the iteration-level

git-svn-id: trunk@17615 -

joost 14 years ago
parent
commit
60ee15200b
2 changed files with 24 additions and 3 deletions
  1. 16 0
      packages/fcl-web/src/base/fphtml.pp
  2. 8 3
      packages/fcl-web/src/base/webpage.pp

+ 16 - 0
packages/fcl-web/src/base/fphtml.pp

@@ -39,6 +39,7 @@ type
   TWebButtons = array of TWebButton;
   TWebButtons = array of TWebButton;
 
 
   TMessageBoxHandler = function(Sender: TObject; AText: String; Buttons: TWebButtons; Loaded: string = ''): string of object;
   TMessageBoxHandler = function(Sender: TObject; AText: String; Buttons: TWebButtons; Loaded: string = ''): string of object;
+  TOnGetUrlProc = procedure(ParamNames, ParamValues, KeepParams: array of string; Action: string; var URL: string) of object;
   TWebController = class;
   TWebController = class;
   THTMLContentProducer = class;
   THTMLContentProducer = class;
 
 
@@ -125,6 +126,7 @@ type
     FAddRelURLPrefix: boolean;
     FAddRelURLPrefix: boolean;
     FBaseURL: string;
     FBaseURL: string;
     FMessageBoxHandler: TMessageBoxHandler;
     FMessageBoxHandler: TMessageBoxHandler;
+    FOnGetURL: TOnGetUrlProc;
     FScriptName: string;
     FScriptName: string;
     FScriptStack: TFPObjectList;
     FScriptStack: TFPObjectList;
     FIterationIDs: array of string;
     FIterationIDs: array of string;
@@ -139,6 +141,7 @@ type
     function GetStyleSheetReferences: TContainerStylesheets; virtual; abstract;
     function GetStyleSheetReferences: TContainerStylesheets; virtual; abstract;
     function GetScripts: TFPObjectList; virtual; abstract;
     function GetScripts: TFPObjectList; virtual; abstract;
     function GetRequest: TRequest;
     function GetRequest: TRequest;
+    property OnGetURL: TOnGetUrlProc read FOnGetURL write FOnGetURL;
   public
   public
     constructor Create(AOwner: TComponent); override;
     constructor Create(AOwner: TComponent); override;
     destructor Destroy; override;
     destructor Destroy; override;
@@ -164,6 +167,7 @@ type
     procedure ShowRegisteredScript(ScriptID: integer); virtual; abstract;
     procedure ShowRegisteredScript(ScriptID: integer); virtual; abstract;
 
 
     function IncrementIterationLevel: integer; virtual;
     function IncrementIterationLevel: integer; virtual;
+    function ResetIterationLevel: integer; virtual;
     procedure SetIterationIDSuffix(AIterationLevel: integer; IDSuffix: string); virtual;
     procedure SetIterationIDSuffix(AIterationLevel: integer; IDSuffix: string); virtual;
     function GetIterationIDSuffix: string; virtual;
     function GetIterationIDSuffix: string; virtual;
     procedure DecrementIterationLevel; virtual;
     procedure DecrementIterationLevel; virtual;
@@ -247,6 +251,7 @@ type
     procedure SetParent(const AValue: TComponent);
     procedure SetParent(const AValue: TComponent);
   Protected
   Protected
     function CreateWriter (Doc : THTMLDocument) : THTMLWriter; virtual;
     function CreateWriter (Doc : THTMLDocument) : THTMLWriter; virtual;
+    function GetIdentification: string; virtual;
     function GetIDSuffix: string; virtual;
     function GetIDSuffix: string; virtual;
     procedure SetIDSuffix(const AValue: string); virtual;
     procedure SetIDSuffix(const AValue: string); virtual;
   protected
   protected
@@ -284,6 +289,7 @@ type
     function MoveContentProducer(MoveElement, MoveBeforeElement: THTMLContentProducer) : boolean;
     function MoveContentProducer(MoveElement, MoveBeforeElement: THTMLContentProducer) : boolean;
     procedure HandleAjaxRequest(ARequest: TRequest; AnAjaxResponse: TAjaxResponse); virtual;
     procedure HandleAjaxRequest(ARequest: TRequest; AnAjaxResponse: TAjaxResponse); virtual;
     procedure ForeachContentProducer(AForeachChildsProc: TForeachContentProducerProc; Recursive: boolean);
     procedure ForeachContentProducer(AForeachChildsProc: TForeachContentProducerProc; Recursive: boolean);
+    property Identification: string read GetIdentification;
     property Childs[Index: integer]: THTMLContentProducer read GetContentProducers;
     property Childs[Index: integer]: THTMLContentProducer read GetContentProducers;
     property AcceptChildsAtDesignTime: boolean read FAcceptChildsAtDesignTime;
     property AcceptChildsAtDesignTime: boolean read FAcceptChildsAtDesignTime;
     property parent: TComponent read FParent write SetParent;
     property parent: TComponent read FParent write SetParent;
@@ -676,6 +682,11 @@ begin
   Result := FChilds;
   Result := FChilds;
 end;
 end;
 
 
+function THTMLContentProducer.GetIdentification: string;
+begin
+  result := '';
+end;
+
 function THTMLContentProducer.ProduceContent: String;
 function THTMLContentProducer.ProduceContent: String;
 var WCreated, created : boolean;
 var WCreated, created : boolean;
     el : THtmlCustomElement;
     el : THtmlCustomElement;
@@ -1440,6 +1451,11 @@ begin
   SetLength(FIterationIDs,Result);
   SetLength(FIterationIDs,Result);
 end;
 end;
 
 
+function TWebController.ResetIterationLevel: integer;
+begin
+  SetLength(FIterationIDs,0);
+end;
+
 procedure TWebController.SetIterationIDSuffix(AIterationLevel: integer; IDSuffix: string);
 procedure TWebController.SetIterationIDSuffix(AIterationLevel: integer; IDSuffix: string);
 begin
 begin
   FIterationIDs[AIterationLevel-1]:=IDSuffix;
   FIterationIDs[AIterationLevel-1]:=IDSuffix;

+ 8 - 3
packages/fcl-web/src/base/webpage.pp

@@ -61,6 +61,8 @@ type
     function CreateNewScript: TStringList; override;
     function CreateNewScript: TStringList; override;
     procedure ShowRegisteredScript(ScriptID: integer); override;
     procedure ShowRegisteredScript(ScriptID: integer); override;
     procedure FreeScript(var AScript: TStringList); override;
     procedure FreeScript(var AScript: TStringList); override;
+  published
+    property OnGetURL;
   end;
   end;
 
 
   { TWebPage }
   { TWebPage }
@@ -89,7 +91,6 @@ type
     procedure DoHandleAjaxRequest(ARequest: TRequest; AnAjaxResponse: TAjaxResponse; var Handled: boolean); virtual;
     procedure DoHandleAjaxRequest(ARequest: TRequest; AnAjaxResponse: TAjaxResponse; var Handled: boolean); virtual;
     procedure DoBeforeRequest(ARequest: TRequest); virtual;
     procedure DoBeforeRequest(ARequest: TRequest); virtual;
     procedure DoBeforeShowPage(ARequest: TRequest); virtual;
     procedure DoBeforeShowPage(ARequest: TRequest); virtual;
-    property WebModule: TFPWebModule read FWebModule;
     procedure DoCleanupAfterRequest(const AContentProducer: THTMLContentProducer);
     procedure DoCleanupAfterRequest(const AContentProducer: THTMLContentProducer);
     procedure SetRequest(ARequest: TRequest); virtual;
     procedure SetRequest(ARequest: TRequest); virtual;
     procedure GetChildren(Proc: TGetChildProc; Root: TComponent); override;
     procedure GetChildren(Proc: TGetChildProc; Root: TComponent); override;
@@ -114,6 +115,7 @@ type
     property ContentProducers[Index: integer]: THTMLContentProducer read GetContentProducer;
     property ContentProducers[Index: integer]: THTMLContentProducer read GetContentProducer;
     property HasWebController: boolean read GetHasWebController;
     property HasWebController: boolean read GetHasWebController;
     property WebController: TWebController read GetWebController write FWebController;
     property WebController: TWebController read GetWebController write FWebController;
+    property WebModule: TFPWebModule read FWebModule;
   published
   published
     property BeforeRequest: TRequestEvent read FBeforeRequest write FBeforeRequest;
     property BeforeRequest: TRequestEvent read FBeforeRequest write FBeforeRequest;
     property BeforeShowPage: TRequestEvent read FBeforeShowPage write FBeforeShowPage;
     property BeforeShowPage: TRequestEvent read FBeforeShowPage write FBeforeShowPage;
@@ -263,7 +265,7 @@ begin
               AComponent:=self;
               AComponent:=self;
               while (i > 0) and (assigned(AComponent)) do
               while (i > 0) and (assigned(AComponent)) do
                 begin
                 begin
-                AComponent := FindComponent(copy(CompName,1,i-1));
+                AComponent := AComponent.FindComponent(copy(CompName,1,i-1));
                 CompName := copy(compname,i+1,length(compname)-i);
                 CompName := copy(compname,i+1,length(compname)-i);
                 i := pos('$',CompName);
                 i := pos('$',CompName);
                 end;
                 end;
@@ -277,6 +279,7 @@ begin
                 if ASuffixID<>'' then
                 if ASuffixID<>'' then
                   begin
                   begin
                   SetIdSuffixes(THTMLContentProducer(AComponent));
                   SetIdSuffixes(THTMLContentProducer(AComponent));
+                  webcontroller.ResetIterationLevel;
                   end;
                   end;
                 THTMLContentProducer(AComponent).HandleAjaxRequest(ARequest, AnAjaxResponse);
                 THTMLContentProducer(AComponent).HandleAjaxRequest(ARequest, AnAjaxResponse);
                 end;
                 end;
@@ -611,7 +614,9 @@ begin
 
 
   p := copy(qs,1,length(qs)-1);
   p := copy(qs,1,length(qs)-1);
   if p <> '' then
   if p <> '' then
-    result := result + ConnectChar + p
+    result := result + ConnectChar + p;
+  if assigned(OnGetURL) then
+    OnGetURL(ParamNames, ParamValues, KeepParams, Action, Result);
 end;
 end;
 
 
 procedure TStandardWebController.BindJavascriptCallstackToElement(AComponent: TComponent; AnElement: THtmlCustomElement; AnEvent: string);
 procedure TStandardWebController.BindJavascriptCallstackToElement(AComponent: TComponent; AnElement: THtmlCustomElement; AnEvent: string);