Scripting in XPages

The scripting contexts are event handlers and formulas. The scripting language is JavaScript™ supplemented by simple actions and expression language (EL).

Event handlers respond to user events such as clicking a button or removing focus from an edit box:
  • An event handler can be specified as JavaScript, a simple action, or a simple action group. A simple action is a pre-programmed activity such as opening a page or creating a response document.
  • A simple action group contains multiple simple actions which are executed in order. You can conditionally execute the group. You can specify multiple groups. One of the simple actions is to execute a script so effectively you can group scripts.
  • Event handlers can be specified for both the client and the server on the same event. The client handler executes before a service request is sent to the server. The server handler executes upon receipt of the request. At any time, a client handler can stop further event processing and block the service request by returning false.
Formulas specify values for controls and properties:
  • A formula can be specified as JavaScript or expression language (EL).
  • The preferred use of EL in XPages is to bind an item in a data source to a control. This is what the XPages UI does when you use the dropdown menus to bind data. For example, the EL expression document1.subject is the same as specifying document1 for Data source and subject for Bind to under simple data binding.
  • Formulas execute on the server either once when the XPage first loads or dynamically whenever the XPage sends a request to the server. The latter is the default.
  • The value applied at run time is the return value of the JavaScript script or the evaluation of the EL expression.