<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.infinite-erp.co.id/index.php?action=history&amp;feed=atom&amp;title=How_To_Implement_JsonDataServiceExtraActions_Hook</id>
	<title>How To Implement JsonDataServiceExtraActions Hook - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.infinite-erp.co.id/index.php?action=history&amp;feed=atom&amp;title=How_To_Implement_JsonDataServiceExtraActions_Hook"/>
	<link rel="alternate" type="text/html" href="https://wiki.infinite-erp.co.id/index.php?title=How_To_Implement_JsonDataServiceExtraActions_Hook&amp;action=history"/>
	<updated>2026-04-06T16:45:07Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.31.1</generator>
	<entry>
		<id>https://wiki.infinite-erp.co.id/index.php?title=How_To_Implement_JsonDataServiceExtraActions_Hook&amp;diff=2813&amp;oldid=prev</id>
		<title>Wikiadmin: Created page with &quot;== Introduction ==  This document explains how to implement '''JsonDataServiceExtraActions''' Hook. This hook is called before and after each operation of ''DefaultJSONDataSer...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.infinite-erp.co.id/index.php?title=How_To_Implement_JsonDataServiceExtraActions_Hook&amp;diff=2813&amp;oldid=prev"/>
		<updated>2021-12-16T05:19:42Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;== Introduction ==  This document explains how to implement &amp;#039;&amp;#039;&amp;#039;JsonDataServiceExtraActions&amp;#039;&amp;#039;&amp;#039; Hook. This hook is called before and after each operation of &amp;#039;&amp;#039;DefaultJSONDataSer...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
This document explains how to implement '''JsonDataServiceExtraActions''' Hook. This hook is called before and after each operation of ''DefaultJSONDataService'' class. &lt;br /&gt;
&lt;br /&gt;
== Hook Implementation ==&lt;br /&gt;
&lt;br /&gt;
The hook is implemented by extending the ''JsonDataServiceExtraActions'' class. This class has two methods to implement:&lt;br /&gt;
&lt;br /&gt;
'''doPreAction''' method:&lt;br /&gt;
&lt;br /&gt;
This void method is called at the beginning of each ''DefaultJSONDataService'' action. It has 3 parameters:&lt;br /&gt;
&lt;br /&gt;
;'''parameters''': The Map with the parameters of the DataSource call.&lt;br /&gt;
;'''data''': ''JSONArray'' with the records that are going to be inserted, updated or deleted. Modify this object in case it is required to modify the data before executing the action. Fetch operations receive an empty array.&lt;br /&gt;
;'''action''': DataSourceAction enum value with the action of the DataSource call. Possible values are FETCH, ADD, UPDATE and REMOVE.&lt;br /&gt;
&lt;br /&gt;
'''doPostAction''' method:&lt;br /&gt;
&lt;br /&gt;
This void method is called at the end of each ''DefaultJSONDataService'' action. It has 4 parameters:&lt;br /&gt;
&lt;br /&gt;
;'''parameters''': The Map with the parameters of the DataSource call.&lt;br /&gt;
;'''content''': JSONObject with the current content that is returned to the client. Modify this object in case it is required to modify the data before is returned.&lt;br /&gt;
;'''action''': DataSourceAction enum value with the action of the DataSource call. Possible values are FETCH, ADD, UPDATE and REMOVE.&lt;br /&gt;
;'''originalObject''': JSONObject String available only on ADD and UPDATE with the original values of the data.&lt;br /&gt;
&lt;br /&gt;
== Example ==&lt;br /&gt;
&lt;br /&gt;
This example logs a line every time a window is loaded. You can find the code described below in the ''org.openbravo.platform.features'' module. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;public class JsonDataServiceExtraActionsExample implements JsonDataServiceExtraActions {&lt;br /&gt;
  private static final Logger log = LoggerFactory&lt;br /&gt;
      .getLogger(JsonDataServiceExtraActionsExample.class);&lt;br /&gt;
&lt;br /&gt;
  @Override&lt;br /&gt;
  public void doPreAction(Map&amp;lt;String, String&amp;gt; parameters, JSONArray newData, DataSourceAction action) {&lt;br /&gt;
    log.debug(&amp;quot;JsonDataServiceExtraActionsExample doPreAction implementation&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  @Override&lt;br /&gt;
  public void doPostAction(Map&amp;lt;String, String&amp;gt; parameters, JSONObject content,&lt;br /&gt;
      DataSourceAction action, String originalObject) {&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:HowTo]]&lt;/div&gt;</summary>
		<author><name>Wikiadmin</name></author>
		
	</entry>
</feed>