Customizing the Presentation Model to Identify the Records to Delete
This task is a step in Process of Customizing the Presentation Model.
In this topic, you modify the list column control that you created in Step 3. This control uses a check box, so you must make sure that Siebel Open UI stores the value of this check box when the user toggles it.
The following figure illustrates the code that you use to customize the presentation model logic to identify the records to delete. Each number in this figure identifies the corresponding step number in the numbered task list that this book includes immediately after this figure.

To customize the presentation model to identify the records to delete
-
In the recyclebinpmodel.js file, add the method that Siebel Open UI must call:
this.AddMethod("LeaveField", PreLeaveField, {sequence:true, scope:this});
where:
-
AddMethod
adds the LeaveField method. To identify the method that you must add when you do your own customization work, you can examine the life cycles that Siebel Open UI uses that most closely meets your business requirement. To view these life cycles, see Life Cycle Flows of User Interface Elements. -
In this example, the business requirement is to save the value in a control. Siebel Open UI saves the value of a control when the user navigates away from the control, so it calls the LeaveField method to handle this requirement. For more information, see LeaveField Method and Flow That Handles Focus Changes in List Applets.
-
PreLeaveField, {sequence : true, scope : this}
configures Siebel Open UI to call your custom LeaveField method before it calls the predefined LeaveField method. It does this during the Init life cycle when it runs the AddMethod method. It is recommended that you set up the presentation model methods at the beginning of the Init life cycle call that contains most of the properties and dependency injections, including predefined and custom methods. For more information about Init, see Life Cycle of User Interface Elements. For more information, see About Dependency Injection.
It is recommended that you use a named method to specify the Prexxx customization method, such as PreLeaveField. This configuration makes sure that Siebel Open UI uses the same method for all presentation model instances. It is not recommended that you specify the Prexxx customization method as an anonymous method in the AddMethod call because Siebel Open UI creates this anonymous method for every presentation model instance that resides in memory, possibly for more than one applet in the same view. Defining an anonymous method in this situation might cause a conflict.
-
-
Create the condition:
if (ctrl.GetName() === "Client_Select"){
The Setup method uses the GetName method with a literal return value of Client_Select. It identifies the method that Siebel Open UI uses for your custom control. For more information, see GetName Method for Applets.
-
Make sure Siebel Open UI returns your custom logic after it sets the CancelOperation part of the return value to true:
returnStructure[ "CancelOperation" ] = true;
This configuration overrides the predefined code when Siebel Open UI calls LeaveField for your new list column. In this example, you must implement LeaveField for the control, so it is not desirable to call the predefined code for this control after Siebel Open UI finishes running your customization of the LeaveField method. For more information about using ReturnStructure when you modify a method, see AddMethod Method.
-
Configure Siebel Open UI to return a value of
true
after it sets the CancelOperation part of returnStructure to true:returnStructure[ "ReturnValue" ] = true;
The LeaveField method returns a value of true to indicate success in this example, so you must make sure Siebel Open UI uses the same logic after your customization finishes running and returns a value. This configuration makes sure the Init life cycle continues on the success path after the custom LeaveField method runs. You can use ReturnValue to make sure Siebel Open UI sets the return value of your custom implementation to the required value. In this example, you set this value to
true
. -
Disable the processing that Siebel Open UI does for the control that is in focus:
this.ExecuteMethod("SetActiveControl", null);
This code sets the active control to null. For more information, see Disabling Automatic Updates and SetActiveControl Method.
-
Add the property that Siebel Open UI uses to store the set of records that are pending deletion:
this.AddProperty("DeletionPendingSet", []);
The set of records that are pending deletion represent the state of your custom presentation model, so you add the DeletionPendingSet property to store the field values for this set of records.
-
Identify the records that Siebel Open UI must delete:
var delObj = this.Get("DeletionPendingSet"); var currentSelection = this.Get("GetSelection"); if(value === "Y"){ delObj[currentSelection] = this.Get("GetRecordSet")[currentSelection]; } else{ delObj[currentSelection] = null; }
Siebel Open UI must identify the records that the user chooses to delete so that it can populate a value into the DeletionPendingSet property. To identify this property, you can examine the properties that the presentation model uses for the applet. This work is similar to the work you do in Step 1 to identify the property in the presentation model that Siebel Open UI uses for lists, except in this topic you examine the properties described in Properties of the Presentation Model That Siebel Open UI Uses for List Applets.
After examining these properties, assume you determine that Siebel Open UI uses the GetSelection property to get the index of the record that the user has chosen from among all the records that Siebel Open UI displays. You also determine that you can use the GetRecordSet property to get this full set of records.
-
Save the recyclebinpmodel.js file.