View source | Discuss this page | Page history | Printable version   
Main Page
Upload file
What links here
Recent changes

PDF Books
Add page
Show collection (0 pages)
Collections help


How To Implement ExtraWindowSettingsInjector Hook


This document explains how to implement ExtraWindowSettingsInjector Hook. This hook is called after each window load, at the end of WindowSettingsActionHandler class.

Hook Implementation

This hook is implemented by extending the ExtraWindowSettingsInjector class has just one method to implement: doAddSetting. This method receives two parameters:

the parameters Map of the current WindowSettingsActionHandler execution.
the JSONObject response instance of the WindowSettingsActionHandler.

It returns a Map<String, Object> 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<String> 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.


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.

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.

public class ExtraSettingsInjectorExample implements ExtraWindowSettingsInjector {
  public Map<String, Object> doAddSetting(Map<String, Object> parameters, JSONObject json)
      throws OBException {
    Map<String, Object> extraSettings = new HashMap<String, Object>();
    String strWindowId = (String) parameters.get("windowId");
    if ("140".equals(strWindowId)) {
      // Set extraSettings
      extraSettings.put("showAlert", true);
      // Set extraCallbacks
      List<String> callbackList = new ArrayList<String>();
      extraSettings.put("extraCallbacks", callbackList);
      // Add extraCallbacks
    return extraSettings;

The JavaScript implementation shows an alert in case the extraSettings.showAlert is true.

OB.OBPF = OB.OBPF || {};
  showAlert: function (data) {
    if (!data|| !data.extraSettings || !data.extraSettings.showAlert) {
    alert("Window opened");

Retrieved from ""

This page has been accessed 801 times. This page was last modified on 7 May 2015, at 09:08. Content is available under Creative Commons Attribution-ShareAlike 2.5 Spain License.