Adding custom code

You test the generated application, and there are modifications you want to make that cannot be done using the business application diagram. You can modify the behavior by adding your own custom code.

Who can create custom code, or a necessary understanding of the architecture

To create your own custom code, you must understand the basics of a Genero application.

The BAM generates applications supporting the Genero BDL user interface architecture. This architecture is based on the Model-View-Controller (MVC) paradigm, which divides the program logic into three interconnected elements:
  • The View visualizes the interface; for example, a form, and how it is displayed to the screen.
  • The Model defines the object to be displayed; typically application data stored in program variables.
  • The Controller sits between the view and model and co-ordinates the interaction. The controller allows you to use dialogs (interactive instruction blocks) to respond to user actions and data input. The MENU, DISPLAY, CONSTRUCT, and INPUT statements are examples of these interactive dialog blocks.

If your modification involves changing the program flow of an interactive dialog, you can write custom code to perform the required actions.

For instance, you might want to write custom code for the following reasons:
  • To display a message to users performing a search indicating that a required value is needed and return the focus to that field.
  • To implement UI action changes; for example, to hide or disable menus depending on whether the dialog is in an input, empty, or search state.

To learn more about the MVC paradigm and working with dialogs, read the Dialog Instructions section of the Genero Business Development Language User Guide.

Options for custom code

You can add custom code using:
  • code events (recommended).

    Using code events is the recommended way to code. Code events appear under Dialog Events, or Data Events in the Properties view. In the event function generated you can add code to perform or modify actions.

  • the POINT and BLOCK method (legacy method).

    Some code events can still only be provided in code links using the POINT or BLOCK method. Access the code using the links found under Code Links in the Properties view.

When you add custom code, it may overwrite default actions implemented by Genero BDL controllers or handlers, or it may add additional actions to be implemented. If it overwrites the default behavior, your code is executed instead. You are responsible for the validity of the code in a code event or block.

Tip: For greatest flexibility, create a custom form, and edit the On Exec code event function.