Program types

Overview

This section aims to give you an overview of the programs you need to develop in 2E to make a business process which can be plugged in to Websydian Express.

The following image gives an overview of the different components used. Each type of component is described in more detail below.

This structure is the one we have used in the example.

Websydian Express Runtime

The Websydian Express Runtime is objects delivered with the installation. The the runtime receives the requests sent from the browser and calls the appropriate programs based on the request.

A ProcessEntryPoint will be called for the first request in a business process, for the rest of the requests an EventHandler will be called.

ProcessEntryPoint

The ProcessEntryPoint is a function you must develop.

Exactly one ProcessEntryPoint function must be developed for each business process defined in Websydian Express.

The ProcessEntryPoint is called automatically by the runtime when a business process, which has the implementation name of the ProcessEntryPoint as Process ID is activated.

Name

The name of the program object for the ProcessEntryPoint must be the same as the Process ID specified for the business process.

Interface

The ProcessEntryPoint can't be called with any parameters.

Functionality

The ProcessEntryPoint just works as an interface between the runtime and the program handling the request.

In most cases the functionality of the ProcessEntryPoint will just be a call to the PageGenerator used to create the first page shown in the business process.

EventHandlers

The EventHandlers are functions you must develop.

One EventHandler must be developed for each event you want to be able to activate in your business process.

The EventHandler function is called automatically when an event that has the object name of the function as event id is activated.

Name

The Name of the EventHandler must correspond to the Event ID specified for the event when defining the template in the PageModeler.

Interface

The interface of the EventHandler must have one input field, a character field (Action) with length 1.

Functionality

If the Action is "R" the program must set blank in the Return code and return to the calling program. This happens when the event is called the first time. It makes it possible for the runtime to register the event received as a valid event.

In all other cases - retrieve the values the user has entered (use the GetInput API) and the parameters set by the PageGenerator function (use the GetParm and ValidateParm APIs).

After retrieving the values entered by the user, you should validate them.

Please note that this is even more important in web applications than in e.g. 5250 applications. You cannot assume that you know anything about the data being retrieved.

For example: Before using a numerical field, you must check that it is actually a numeric value which has been entered, whereas this is normally ensured by the definitions in a 5250 display file.

After validating the values, you can use them in the program - e.g. for updating the database.

Finally, call the PageGenerator function that will send the reply page to the browser. Each EventHandler must ensure that a PageGenerator is called as the last step before the program is terminated.

PageGenerators

The PageGenerators are functions you must develop.

One PageGenerator must be developed for each page you want to be able to show to the user.

Name

No restrictions.

Interface

No restrictions.

Functionality

Each PageGenerator is used to populate a specific template with values for the variables that has been defined for the template.

The PageGenerator can either get these values from input fields or by reading the database/making calculations etc.

After finding the values, the SetOutput/SetGridOutput APIs are used to make the values available for the function that creates the webpage by merging the template with the values set by the PageGenerator.

Please note that the values you write to the page using these APIs are just character strings. You must ensure that any formatting of these strings is done before you write them to the page.

The SetParm, SetGridParm APIs can be used to specify parameters for events specified in the template.

The Write Page API is called just before the PageGenerator terminates - this API merges the values specified in the program with the template, to create the webpage that is sent to the browser.