Browse Source

* Do not call only BeforeGenerateContent of child producers, but also for the producer itself
* Call BeforeGenerateContent of childs from a TWebPageProducer

git-svn-id: trunk@14839 -

joost 15 years ago
parent
commit
75ff11b24f
1 changed files with 15 additions and 0 deletions
  1. 15 0
      packages/fcl-web/src/fphtml.pp

+ 15 - 0
packages/fcl-web/src/fphtml.pp

@@ -249,6 +249,7 @@ type
     procedure DoWriteVisualHeader (aWriter : THTMLWriter); virtual;
     procedure DoWriteVisualBody (aWriter : THTMLWriter); virtual;
     procedure DoWriteVisualFooter (aWriter : THTMLWriter); virtual;
+    procedure BeforeGenerateContent; override;
     Property HeaderProducer : THTMLContentProducer read FHeaderProducer write FHeaderProducer;
     Property VisualHeaderProducer : THTMLContentProducer read FVisualHeaderProducer write FVisualHeaderProducer;
     Property VisualBodyProducer : THTMLContentProducer read FVisualBodyProducer write FVisualBodyProducer;
@@ -541,6 +542,7 @@ begin
       el := WriteContent (FWriter);
       if not assigned(el) then
         Raise EHTMLError.CreateFmt(SErrNoContentProduced,[Self.Name]);
+      BeforeGenerateContent;
       ForeachContentProducer(@DoBeforeGenerateContent,True);
       result := el.asstring;
     finally
@@ -1071,6 +1073,19 @@ begin
     aWriter.AddElement(FVisualFooterProducer.WriteContent(aWriter));
 end;
 
+procedure THTMLCustomPageProducer.BeforeGenerateContent;
+begin
+  inherited BeforeGenerateContent;
+  if assigned(FHeaderProducer) then
+    FHeaderProducer.BeforeGenerateContent;
+  if assigned(FVisualHeaderProducer) then
+    FVisualHeaderProducer.BeforeGenerateContent;
+  if assigned(FVisualBodyProducer) then
+    FVisualBodyProducer.BeforeGenerateContent;
+  if assigned(FVisualFooterProducer) then
+    FVisualFooterProducer.BeforeGenerateContent;
+end;
+
 constructor THTMLCustomPageProducer.Create(AOwner: TComponent);
 begin
   inherited Create(AOwner);