Open a popup window

This procedure shows you how to open a popup window to display a message to the user.

About this task

The function that implements this popup window is defined in a JavaScript module that implements GBC custom front call functions.

  1. In the gbc-project-dir/customization/customization-project-dir/js directory, add a js file called myFrontCallModule.js:
    // in myFrontCallModule.js
    "use strict";
    
    modulum('FrontCallService.modules.myFrontCallModule', ['FrontCallService'],
        /**
         * @param {gbc} context
         * @param {classes} cls
         */
        function (context, cls) {
            context.FrontCallService.modules.myFrontCallModule = {
    
                myalert: function (mytext) {
                    alert(mytext);
                    return ["0"];
                },
            };
        }
    );

    In this example the customization calls the JavaScript alert() method to display an alert box with a message and an OK button. When the alert box pops up, the user will have to click OK to proceed. The text (mytext) to display in the alert box is provided in the front call.

  2. Save your changes and rebuild your customization using gbc build:
    $ gbc build --customization customization-project-dir
  3. View the changes by opening an app with a front call command.
    DEFINE res STRING
    MAIN
      OPEN WINDOW w1 WITH FORM "HelloForm" ATTRIBUTES( style="dialog2" )
      MENU
         ON ACTION QUIT
            CALL ui.Interface.frontCall( "myFrontCallModule","myalert", ["Goodbye!"] , [] )
            DISPLAY res
            EXIT MENU
         ON ACTION CLOSE
           EXIT MENU
      END MENU
      CLOSE WINDOW w1
    END MAIN
    Figure: Pop-up alert window