Implement front call modules for GWC - HTML5 theme

Custom front call modules for the GWC-HTML5 theme front-end are implemented by using JavaScriptâ„¢.

GWC-HTML5 theme custom front call basics

When using the GWC-HTML5 theme, front-end calls are JavaScript functions executed locally on the workstation where the browser is running.

Note: Executing front calls in the context of a web browser is limited to the OS functions a web browser can do. For example, it will not be possible to delete a file on the computer where the browser executes.
To implement custom front calls for GWC-HTML5 theme, you must edit the csf.js JavaScript file located in $FGLASDIR/tpl/SetHtml5. Genero built-in front calls and custom front calls are implemented in the csf.js file.
Important: Custom front call module and function names must be registered in lowercase for the GWC-HTML5 theme front-end.
Follow these steps to implement a custom front call module for the GWC-HTML5 theme:
  1. Edit the $FGLASDIR/tpl/SetHtml5/csf.js file.
  2. Add a JavaScript object using the name of the front call module to the gwc.frontCallModuleList object:
    gwc.frontCallModuleList.mymodule = { ... }
  3. Add your front call functions as JavaScript methods to the newly-created module object (with potential parameters):
    gwc.frontCallModuleList.mymodule = { 
         myfunction : function ( param1, ... ) {
             ...
         }
    }

    The parameters of the JavaScript method must match the parameter list of the ui.Interface.frontCall("mymodule", "myfunction", [param-list], [return-list]).

  4. If the front call must return values to the Genero program, add a return instruction in the JavaScript method:
        return ( [value1, ... ]);

    The number of returned values must match the number of variables used in the return list of the Genero front call ui.Interface.frontCall("mymodule", "myfunction", [param-list], [return-list]).

    If the front call does not return any value to the Genero program, the JavaScript method must return an empty list:
        return [];
Note:
  • If the SetHtml5 directory contains compressed .js files, do not forget to compress the modified csf.js file, or remove the compressed version of the file (the GAS will use the non-compressed version).
  • Keep in mind that the JavaScript modules can be cached in your browser. You may need to refresh the cache when doing modifications in the csf.js file.
  • Make sure to save your custom front call definitions added to csf.js before installing a new version of the GAS; the existing csf.js will be overwritten by the new installation.
  • Front call module and function names are case sensitive.

Example

Add the following lines in the csf.js file:

gwc.frontCallModuleList.mymodule = {
  myfunction1: function(param) {
    alert("param: " + param);
    return [];
  }
  myfunction2: function(param1,param2) {
    alert("param1: " + param1 + "\nparam2: " + param2);
    return [55,"aaa"];
  }
};
The above JavaScript code implements a front call module list with functions that can be called from the Genero programs as follows:
DEFINE r INTEGER, s STRING
CALL ui.Interface.frontCall("mymodule", "myfunction1", ["abc"], [] )
CALL ui.Interface.frontCall("mymodule", "myfunction2", [123,"abc"], [r,s] )