Просмотр исходного кода

* Added protected, virtual TWebPage.IsAjaxCall

git-svn-id: trunk@14958 -
joost 15 лет назад
Родитель
Сommit
805a6c3572
1 измененных файлов с 10 добавлено и 4 удалено
  1. 10 4
      packages/fcl-web/src/webpage.pp

+ 10 - 4
packages/fcl-web/src/webpage.pp

@@ -67,6 +67,7 @@ type
     procedure DoHandleAjaxRequest(ARequest: TRequest; AnAjaxResponse: TAjaxResponse; var Handled: boolean); virtual;
     procedure DoBeforeRequest(ARequest: TRequest); virtual;
     procedure DoBeforeShowPage(ARequest: TRequest); virtual;
+    function IsAjaxCall: boolean; virtual;
     property WebModule: TFPWebModule read FWebModule;
     procedure DoCleanupAfterRequest(const AContentProducer: THTMLContentProducer);
     procedure SetRequest(ARequest: TRequest); virtual;
@@ -164,8 +165,7 @@ begin
 end;
 
 procedure TWebPage.HandlePage(ARequest: TRequest; AResponse: TResponse; AWriter: THTMLwriter; AWebModule: TFPWebModule=nil);
-var s : string;
-    Handled: boolean;
+var Handled: boolean;
     CompName: string;
     AComponent: TComponent;
     AnAjaxResponse: TAjaxResponse;
@@ -175,8 +175,7 @@ begin
   try
     try
       DoBeforeRequest(ARequest);
-      s := Request.HTTPXRequestedWith;
-      if sametext(s,'XmlHttpRequest') then
+      if IsAjaxCall then
         begin
         AnAjaxResponse := TAjaxResponse.Create(GetWebController, AResponse);
         try
@@ -310,6 +309,13 @@ begin
     BeforeShowPage(Self,ARequest);
 end;
 
+function TWebPage.IsAjaxCall: boolean;
+var s : string;
+begin
+  s := Request.HTTPXRequestedWith;
+  result := sametext(s,'XmlHttpRequest');
+end;
+
 { TStandardWebController }
 
 function TStandardWebController.GetScriptFileReferences: TStringList;