How To Implement FICExtension Hook

From InfiniteERP Wiki
Jump to: navigation, search

Introduction

This document explains how to implement the FICExtension Hook. The hook is executed in the execute method of the FormInitializationComponent class just before the response is built.

Hook Implementation

This hook is implemented by extending the FICExtension class. It has just one void method to implement: execute. This method receives as parameters the instances of the objects used to build the response.

mode
The execution mode.
tab
The Tab owner of the Form that it is being executed.
columnValues
Map with the values of forms columns.
row
The BaseOBObject that it is being edited in the form.
changeEventCols
The List of dynamic columns that fire the CHANGE event mode.
calloutMessages
The List of messages returned by the callouts that have been executed.
attachments
The List with the attachments related to the record that it is being edited.
jsExcuteCode
The List of JavaScript code returned by the callouts to be executed in the client.
hiddenInputs
The Map with all the hidden fields with their values.
noteCount
count of notes available on the record that it is being edited.
overwrittenAuxiliaryInputs
The List of the Auxiliary Inputs overriden by callouts.


Example

This example shows a message every time a new product is edited. You can find the code described below in the org.openbravo.platform.features module.

<source lang="java">public class ProductFICExtensionExample implements FICExtension {

@Override
 public void execute(String mode, Tab tab, Map<String, JSONObject> columnValues, BaseOBObject row,
     List<String> changeEventCols, List<JSONObject> calloutMessages, List<JSONObject> attachments,
     List<String> jsExcuteCode, Map<String, Object> hiddenInputs, int noteCount,
     List<String> overwrittenAuxiliaryInputs) throws OBException {
   if ("180".equals(tab.getId())) {
     JSONObject jsonMessage = new JSONObject();
     try {
       jsonMessage.put("severity", "TYPE_WARNING");
       jsonMessage.put("text", "Product form opened");
     } catch (JSONException ignore) {
     }
     calloutMessages.add(jsonMessage);
   }
 }

} </source>