Customizing your application using front calls

Custom front calls allow you to customize the behavior, layout and appearance of your application. For example, you can use a front call to specify the header or footer text or raise an alert with a customized message.

It is possible to implement custom front-end functions to interface with GBC features, and use the feature from a Genero program through a front call. For example, you can implement a front-end function module to interface with a JavaScript popup window to alert the user or confirm an action.

To create a custom front call you require some knowledge of JavaScript as front-end calls are JavaScript functions executed locally on the workstation where the browser is running. You may also need to extend GBC widgets as part of the customization.

Required files

  • A JavaScript (.js) file with JavaScript functions that implement your custom front calls must have the structure shown in the example.
    "use strict";
    
    modulum('FrontCallService.modules.mymodule', ['FrontCallService'],
      /**
       * @param {gbc} context
       * @param {classes} cls
       */
      function(context, cls) {
        context.FrontCallService.modules.mymodule = {
    
          myfunc: function (name) {
            if (name === undefined) {
              this.parametersError();
              return;
            }
            if (name.length === 0) {
              this.runtimeError("name shouldn't be empty");
              return;
            }
            return ["Hello, " + name + " !"];
          }
    
        };
      }
    );

    Where:

    1. mymodule is the name of the front call module, and corresponds to the first parameter of ui.Interface.frontCall().
    2. myfunc is the name of the front call function, and corresponds to the second parameter of ui.Interface.frontCall().
    3. The JavaScript functions this.parametersError() and this.runtimeError correspond to two functions from the GBC front call API that implement error handling.
    For more information, see the Implement front call modules for GBC page in the Genero Business Development Language User Guide.
  • If a built-in widget does not meet your needs, you may also need to extend a widget by creating a template HTML (.tpl.html) file containing the HTML code structure of the widget. For more information on extending widgets, see Customizing your application using widgets.

Genero BDL program

Executing a call to your custom front call from the Genero BDL program requires a call to the ui.Interface.frontCall():

DEFINE res STRING
CALL ui.Interface.frontcall( "mymodule","myfunc", ["world"] , [res] )
DISPLAY res