<?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_ExtraWindowSettingsInjector_Hook</id>
	<title>How To Implement ExtraWindowSettingsInjector 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_ExtraWindowSettingsInjector_Hook"/>
	<link rel="alternate" type="text/html" href="https://wiki.infinite-erp.co.id/index.php?title=How_To_Implement_ExtraWindowSettingsInjector_Hook&amp;action=history"/>
	<updated>2026-04-06T21:44:01Z</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_ExtraWindowSettingsInjector_Hook&amp;diff=2814&amp;oldid=prev</id>
		<title>Wikiadmin: Created page with &quot;== Introduction ==  This document explains how to implement '''ExtraWindowSettingsInjector''' Hook. This hook is called after each window load, at the end of ''WindowSettingsA...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.infinite-erp.co.id/index.php?title=How_To_Implement_ExtraWindowSettingsInjector_Hook&amp;diff=2814&amp;oldid=prev"/>
		<updated>2021-12-16T05:20:29Z</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;ExtraWindowSettingsInjector&amp;#039;&amp;#039;&amp;#039; Hook. This hook is called after each window load, at the end of &amp;#039;&amp;#039;WindowSettingsA...&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 '''ExtraWindowSettingsInjector''' Hook. This hook is called after each window load, at the end of ''WindowSettingsActionHandler'' class.&lt;br /&gt;
&lt;br /&gt;
== Hook Implementation ==&lt;br /&gt;
&lt;br /&gt;
This hook is implemented by extending the ''ExtraWindowSettingsInjector'' class has just one method to implement: ''doAddSetting''. This method receives two parameters:&lt;br /&gt;
&lt;br /&gt;
;'''parameters''': the parameters Map of the current ''WindowSettingsActionHandler'' execution.&lt;br /&gt;
;'''json''': the JSONObject response instance of the ''WindowSettingsActionHandler''.&lt;br /&gt;
&lt;br /&gt;
It returns a Map&amp;lt;String, Object&amp;gt; with all the extra settings desired to be included in the ''WindowSettingsActionHandler'' response. These extra settings are included in the callbacks response ''data'' object inside the ''extraSettings'' property. If the ''WindowSettingsActionHandler.EXTRA_CALLBACK'' key is used with a String or List&amp;lt;String&amp;gt; as value it is possible to return some JavaScript function names that are executed on the callback of the ''WindowSettingsActionHandler''. These JavaScript functions can be implemented to use the extraSettings included in the Map. These function only receipt the original ''data'' object of the callback as argument.&lt;br /&gt;
&lt;br /&gt;
== Example ==&lt;br /&gt;
&lt;br /&gt;
This example shows an alert every time the ''Product'' window is loaded. You can find the code described below in the ''org.openbravo.platform.features'' module. &lt;br /&gt;
&lt;br /&gt;
The java implementation add an extra setting called ''showAlert'' with the boolean ''true'' as  its value. It also adds the ''OB.OBPF.showAlert'' JavaScript function using the ''extraCallbacks'' key.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;public class ExtraSettingsInjectorExample implements ExtraWindowSettingsInjector {&lt;br /&gt;
&lt;br /&gt;
  @Override&lt;br /&gt;
  public Map&amp;lt;String, Object&amp;gt; doAddSetting(Map&amp;lt;String, Object&amp;gt; parameters, JSONObject json)&lt;br /&gt;
      throws OBException {&lt;br /&gt;
    Map&amp;lt;String, Object&amp;gt; extraSettings = new HashMap&amp;lt;String, Object&amp;gt;();&lt;br /&gt;
    String strWindowId = (String) parameters.get(&amp;quot;windowId&amp;quot;);&lt;br /&gt;
    if (&amp;quot;140&amp;quot;.equals(strWindowId)) {&lt;br /&gt;
&lt;br /&gt;
      // Set extraSettings&lt;br /&gt;
      extraSettings.put(&amp;quot;showAlert&amp;quot;, true);&lt;br /&gt;
&lt;br /&gt;
      // Set extraCallbacks&lt;br /&gt;
      List&amp;lt;String&amp;gt; callbackList = new ArrayList&amp;lt;String&amp;gt;();&lt;br /&gt;
      extraSettings.put(&amp;quot;extraCallbacks&amp;quot;, callbackList);&lt;br /&gt;
&lt;br /&gt;
      // Add extraCallbacks&lt;br /&gt;
      callbackList.add(&amp;quot;OB.OBPF.showAlert&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    return extraSettings;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The JavaScript implementation shows an alert in case the ''extraSettings.showAlert'' is ''true''.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;OB.OBPF = OB.OBPF || {};&lt;br /&gt;
&lt;br /&gt;
OB.OBPF = {&lt;br /&gt;
  showAlert: function (data) {&lt;br /&gt;
&lt;br /&gt;
    if (!data|| !data.extraSettings || !data.extraSettings.showAlert) {&lt;br /&gt;
      return;&lt;br /&gt;
    }&lt;br /&gt;
    alert(&amp;quot;Window opened&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:HowTo]]&lt;/div&gt;</summary>
		<author><name>Wikiadmin</name></author>
		
	</entry>
</feed>