summaryrefslogtreecommitdiff
path: root/packages/fcl-web/src/webdata/extjsjson.pp
diff options
context:
space:
mode:
authormichael <michael@3ad0048d-3df7-0310-abae-a5850022a9f2>2010-08-30 07:39:39 +0000
committermichael <michael@3ad0048d-3df7-0310-abae-a5850022a9f2>2010-08-30 07:39:39 +0000
commitccad9dfd758847bd587f9c03d7d6f4c3daaba8e7 (patch)
tree851ad9ebca9c67049c7586df1202d5d6e40af954 /packages/fcl-web/src/webdata/extjsjson.pp
parent18c832d1fe4b1bf8f490a63c7e4cab0337ed2716 (diff)
downloadfpc-ccad9dfd758847bd587f9c03d7d6f4c3daaba8e7.tar.gz
* After insert/update/delete events
git-svn-id: http://svn.freepascal.org/svn/fpc/trunk@15920 3ad0048d-3df7-0310-abae-a5850022a9f2
Diffstat (limited to 'packages/fcl-web/src/webdata/extjsjson.pp')
-rw-r--r--packages/fcl-web/src/webdata/extjsjson.pp21
1 files changed, 16 insertions, 5 deletions
diff --git a/packages/fcl-web/src/webdata/extjsjson.pp b/packages/fcl-web/src/webdata/extjsjson.pp
index d93379bfc4..9847a0d35c 100644
--- a/packages/fcl-web/src/webdata/extjsjson.pp
+++ b/packages/fcl-web/src/webdata/extjsjson.pp
@@ -31,12 +31,15 @@ type
TExtJSJSONDataFormatter = Class(TExtJSDataFormatter)
private
FAfterDataToJSON: TJSONObjectEvent;
+ FAfterDelete: TJSONObjectEvent;
+ FAfterInsert: TJSONObjectEvent;
FAfterRowToJSON: TJSONObjectEvent;
+ FAfterUpdate: TJSONObjectEvent;
FBeforeDataToJSON: TJSONObjectEvent;
FBeforeRowToJSON: TJSONObjectEvent;
FOnErrorResponse: TJSONExceptionObjectEvent;
FOnMetaDataToJSON: TJSONObjectEvent;
- procedure SendSuccess(ResponseContent: TStream; AddIDValue : Boolean = False);
+ procedure SendSuccess(ResponseContent: TStream; AddIDValue : Boolean = False; CallBack : TJSONObjectEvent = Nil);
protected
Function CreateAdaptor(ARequest : TRequest) : TCustomWebdataInputAdaptor; override;
Function AddFieldToJSON(O: TJSONObject; AFieldName: String; F: TField): TJSONData;
@@ -66,6 +69,12 @@ type
Property BeforeDataToJSON : TJSONObjectEvent Read FBeforeDataToJSON Write FBeforeDataToJSON;
// Called when an exception is caught and formatted.
Property OnErrorResponse : TJSONExceptionObjectEvent Read FOnErrorResponse Write FOnErrorResponse;
+ // After a record was succesfully updated
+ Property AfterUpdate : TJSONObjectEvent Read FAfterUpdate Write FAfterUpdate;
+ // After a record was succesfully inserted.
+ Property AfterInsert : TJSONObjectEvent Read FAfterInsert Write FAfterInsert;
+ // After a record was succesfully inserted.
+ Property AfterDelete : TJSONObjectEvent Read FAfterDelete Write FAfterDelete;
end;
implementation
@@ -368,7 +377,7 @@ begin
end;
end;
-procedure TExtJSJSONDataFormatter.SendSuccess(ResponseContent: TStream; AddIDValue : Boolean = False);
+procedure TExtJSJSONDataFormatter.SendSuccess(ResponseContent: TStream; AddIDValue : Boolean = False; CallBack : TJSONObjectEvent = Nil);
Var
Resp : TJSonObject;
@@ -379,6 +388,8 @@ begin
Resp:=TJsonObject.Create;
Resp.Add(SuccessProperty,True);
Resp.Add(Provider.IDFieldName,Provider.IDFieldValue);
+ If Assigned(CallBack) then
+ CallBack(Self,Resp);
L:=Resp.AsJSON;
ResponseContent.WriteBuffer(L[1],Length(L));
finally
@@ -390,19 +401,19 @@ procedure TExtJSJSONDataFormatter.DoInsertRecord(ResponseContent: TStream);
begin
Inherited;
- SendSuccess(ResponseContent,True);
+ SendSuccess(ResponseContent,True,FAfterInsert);
end;
procedure TExtJSJSONDataFormatter.DoUpdateRecord(ResponseContent: TStream);
begin
inherited DoUpdateRecord(ResponseContent);
- SendSuccess(ResponseContent,False);
+ SendSuccess(ResponseContent,False,FAfterUpdate);
end;
procedure TExtJSJSONDataFormatter.DoDeleteRecord(ResponseContent: TStream);
begin
inherited DoDeleteRecord(ResponseContent);
- SendSuccess(ResponseContent,False);
+ SendSuccess(ResponseContent,False,FAfterDelete);
end;
{ TExtJSJSonWebdataInputAdaptor }