Example of Using AttachEventHandler
Assume a presentation model named pmodel.js includes an OnControlEvent method that runs a custom event handler, and that Siebel Open UI sends an eventConfig object as the last argument in the event handler call. It uses this eventConfig object in the custom presentation model to set a value for SWE_EXTN_CANCEL_ORIG_OP or SWE_EXTN_STOP_PROP_OP. This configuration allows AttachEventHandler to create multiple custom events and to stop an event handler from running.
For example, assume your customization configures Siebel Open UI to do the following:
Derive derivedpm1.js from pmodel.js.
Derive derivedpm2.js from derivedpm1.js.
Derive derivedpm3.js from derivedpm2.js.
Include an event handler for PHYEVENT_COLUMN_FOCUS in derivedpm1.js, derivedpm2.js, and derivedpm3.js.
Use derivedpm3.js to set the AttachEventHandler to the value that SWE_EXTN_STOP_PROP_OP contains.
Use the following code so that Siebel Open UI uses the last argument that AttachEventHandler specifies:
this.AttachEventHandler( siebConsts.get("PHYEVENT_COLUMN_FOCUS"), function() { SiebelJS.Log("Control focus 1"); arguments[arguments.length - 1][consts.get("SWE_EXTN_STOP_PROP_OP")] = false; });
Siebel Open UI runs AttachEventHandler customizations in a LIFO (last in, first out) sequence. In this example, it uses the following sequence:
Runs event handlers that reside in derivedpm3.js.
Runs event handlers that reside in derivedpm2.js.
Runs event handlers that reside in derivedpm1.js.
Runs event handlers that reside in the predefined presentation model.
So, this example stops the custom PHYEVENT_COLUMN_FOCUS event handlers in the derivedpm2.js file and the derivedpm1.js file from running.