Configuring Siebel Open UI > Example of Customizing Siebel Open UI > Process of Customizing the Presentation Model >

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 if the user toggles it.

Figure 19 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.

Figure 19. Customizing the Presentation Model Logic to Identify the Records to Delete

To customize the presentation model to identify the records to delete

  1. 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 to add when you do your own customization work, you can examine the flowcharts for the life cycle that Siebel Open UI uses that meets your business requirement. To view these flowcharts, 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 instance of the presentation model 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.

  2. 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 Applet Controls.

  3. 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.

  4. 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.

  5. 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.

  6. 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.

  7. 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 Applets.

    After examining these properties, you find 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 find that you can use the GetRecordSet property to get this full set of records.

  8. Save the recyclebinpmodel.js file.

About Dependency Injection

Dependency injection is a software technique that Siebel Open UI uses to create a dependency between a presentation model and a physical renderer. If Siebel Open UI modifies a method or property that resides in the presentation model, then it also modifies a method or property that resides in the physical renderer. It allows Siebel Open UI to implement logic at run time rather than during a compile. These dependency injections allow Siebel Open UI to use an injected dependency chain, which is a series of two or more dependency injections. You can modify Siebel Open UI to make this chaining depend on conditions that Siebel Open UI modifies at run time. It can use all the methods that the Init method references in Summary of Presentation Model Methods for dependency injection. For an example that uses dependency injection, see Customizing the Physical Renderer to Refresh the Recycle Bin.

Disabling Automatic Updates

Siebel Open UI sends updated field values to the Siebel Server for any fields that the user has modified in the client. In this example, you must disable this update functionality for the current control. You can reference the documentation for the predefined applet to identify the presentation model property that you must modify. In this situation, the documentation indicates that you can configure Siebel Open UI to use the SetActiveControl property of the active control on the applet and set it to null. For more information, see Disabling Automatic Updates, SetProperty Method, and SetActiveControl Method.

ExecuteMethod calls a method that resides in the presentation model. It makes sure that Siebel Open UI runs all injected dependency chains that the method requires when it runs. You must use ExecuteMethod to call any predefined or custom method that resides in a presentation model. For more information, see About Dependency Injection and ExecuteMethod Method.

Configuring Siebel Open UI Copyright © 2013, Oracle and/or its affiliates. All rights reserved. Legal Notices.