IBM BPM, V8.0.1, All platforms > Create processes in IBM Process Designer > Create user interfaces for business processes > Coach and Coach View reference information > Event handlers

The validate event handler

The validate function handles validation errors that are caused by the data in the Coach View.


Usage

The validate function contains the logic to display indicators or some other notifier that there is a problem with the data. The framework starts with the validate function in parent Coach Views before it calls the validate function in their children Coach Views.

The validate event handler is for when you want to provide custom error visualizations and behavior. See the stock controls for examples of presentation logic.

For example, the Text stock control changes color and displays an error icon when it contains non-valid data. The error icon has hover help that displays the message that is associated with the error condition.


The event object

The validate function takes a single event object. The type of the event object is error or clear. An error event means that a validation service or script has detected one or more errors and that the Coach View must handle the errors to display an appropriate visualization. A clear event means that the Coach View must remove the visualization that resulted from an earlier error event.

An error event can have two lists of error objects. One list is named errors and the other is named errors_subscription. Coach Views that are bound to a business object automatically receive errors for themselves. They also automatically receive errors for all descendant Coach Views that are bound to the same business object.

Properties of the error objects in the errors list
Property Type Description
binding String Contains the path to the data binding relative to the data binding of the current Coach View.
message String Contains the localized message that describes the error.
view_dom_ids[] String[List] Contains the list of DOM IDs of the Coach Views that receive the same error message. The list can include the current Coach View and any of its descendant Coach Views.
Coach Views that call subscribeValidation() receive certain errors in the errors_subscription list. These errors occur in descendant Coach Views that are bound to a different business object than the current Coach View. Coach Views that do not have a data binding, such as the Tab stock control, must call subscribeValidation() to receive errors.

Properties of the error objects in the errors_subscription list
Property Type Description
messages String[List] Contains a list of localized error messages
view_dom_id String Contains the DOM ID of the Coach View with the non-valid data.
An error event object might look like this example:

type: "error", errors: 
	[
		{
			binding: "birthday.year"
			message: "The year you entered, 2013, is after current year of 2012.", 			view_dom_ids: ["domId_ProfileView", "domId_yearView"]
		} 	]
errors_subcription: 
	[
		{
			view_dom_id: "domId_accountView", 			messages: ["Enter your account number."]
		} 	]

A clear event object contains no properties. A Coach View uses the clear object to remove the error indicators for Coach Views that now have valid data.

Event handlers


Related concepts:
Example: validating a Coach with a service


Related reference:
The load event handler
The unload event handler
The view event handler