Overview: Adding Events to Forms

You can associate three types of events with automatic form behavior: On Form Load, On Form Show, and On Form Submit. The following sections provide additional detail on each of these event types.

On Form Load

A form must to be loaded into memory before it is shown to the user. The On Form Load event is called when a form has been loaded. This occurs before On Form Show, and only occurs again when the form needs to be reloaded (whether due to an intentional reload triggered by a Display Form action, or because the application is stopped and restarted).

On Form Show

Once a form is loaded, it is displayed to the user (either in a browser or through the Presentation Renderer). Just before being displayed, the On Form Show event is called. This event is called every time the form is displayed. Generally, a form will be loaded only once but may be shown to the user many times.

On Form Submit

A form is considered submitted once a user has interacted with it in a way that causes data to be sent to the server. After that data is sent and before the form is replaced by another, the On Form Submit event is called. This event has access to any input the user has entered into the form.

Form Event Order

The first event that occurs when an application is started is Application Startup. Then, the On Form Load for the first form occurs, then On Form Show. After that, the form event order depends on the application and what the user does with it.

Form event order

In this diagram, the application consists of three forms: A, B, and C. When interacting with A, the On Form Submit event causes the application to load Form B. From Form B, a submit can either send data to the host and remain at the same form (shown by the curved arrow), or cause the application to load Form C (shown by the straight arrow). If the submit event does not move the application to a new form, the On Form Load event will not be triggered, but the On Form Show will.

If an event caused the application to move from Form C back to Form A, the On Form Load would be triggered again, even if the application had already displayed Form A.

If you have an action that takes a lot of time or resources, such as loading a database of images, you could structure your application so that the action occurs in the On Form Load event, and then have users interact with the database of images from that form. This design would limit the impact of the lengthy database access action.

If you have an action that displays data that you want to keep as current as possible, you would want to add that action to the On Form Show event, because it will occur in more scenarios than the On Form Load event.

Related Topics
Bullet Adding Events, Overview
Bullet Adding Events to Forms
Bullet Editing Command Key Events
Bullet Adding Actions to Events