Configuring Siebel Open UI > Siebel Open UI Application Programming Interface > Classes and Methods of the Siebel Open UI Application Programming Interface >

Presentation Model Class


This topic describes the presentation model class. It includes the following topics:

Siebel Open UI defines the presentation model class in the pmodel.js file. It stores this file in the following folder:

vob_src_locale\src\core\locale\base\ssa\swe\siebel

Init Method

The Init method allows you to use different methods to customize a presentation model, such as AddMethod, AddNotificationHandler, AttachPMBinding, and so forth. It uses the following syntax:

Init()

You must configure Siebel Open UI to use the Init function in the derived presentation model to create customization for this derived presentation model.

You must not override any method except the Init or Setup methods in the derived presentation model.

You must configure Siebel Open UI to do the following:

  • Call the Init method in the predefined presentation model before it calls the Init method in the derived presentation model.
  • Call the Setup method in the predefined presentation model before it calls the Setup method in the derived presentation model.

For more information, see Notifications That Siebel Open UI Supports.

Setup Method

Siebel Open UI calls the Setup method when it processes the initial response from the Siebel Server. It uses the following syntax:

Setup( propertySet )

where:

  • propertySet identifies the property set that Siebel Open UI uses with the corresponding proxy object. It contains the proxy level property set information and any custom property set information that Siebel Open UI added through the presentation model that resides on the Siebel Server. If Siebel Open UI must unmarshall a custom property set, then this work must occur in the Setup function for the derived presentation model.

For example, the following code identifies the childPropset property set:

extObject.Setup( childPropset.GetChild( 0 ));

AddProperty Method

The AddProperty method adds a property to the Presentational Model. Siebel Open UI can access it through the Get function. It returns one of the following values:

  • True. Added a property successfully.
  • False. Did not add a property successfully.

It uses the following syntax:

this.AddProperty( "propertyName", propertyValue );

where:

  • propertyName is a string that identifies a property. A subsequent call to this method with the same propertyName overwrites the previous value.
  • propertyValue assigns a value to the property.

For example, the following code adds the NumOfRows property and assigns a value of 10 to this property:

this.AddProperty( "NumOfRows", 10 );
SiebelJS.Log( this.Get( "NumOfRows" ) );

SetProperty Method

The SetProperty method sets the value of a property in a presentation model. It returns one of the following values:

  • True. Set the property value successfully.
  • False. Did not set the property value successfully.

It uses the following syntax:

SetProperty( propName, propDef )

If the property that the SetProperty method references does not exist, then Siebel Open UI creates this property and sets the value for it according to the SetProperty method. You can also use the AddProperty method to add a property.

Get Method

The Get method returns the value of the property that Siebel Open UI adds through the AddProperty method. If Siebel Open UI passes a function in the propertyValue parameter of the AddProperty method, then Siebel Open UI calls this function and passes the return value to the method that calls the Get.

AddMethod Method

The AddMethod method adds a method to a presentation model. You can use ExecuteMethod to run the method that AddMethod adds from the presentation model or from the physical renderer. If AddMethod attempts to add a new method that the predefined client already contains, then the new method becomes a customization of the predefined method, and this customization runs before or after the predefined method depending on an argument that Siebel Open UI sends when it adds the method. A method that customizes a method can return to the caller without running the predefined method. To do this, you set the CancelOperation property to true. You set this property on the ReturnStructure object that Siebel Open UI sends to each method as an argument.

The AddMethod method returns one of the following values:

  • True. Added a method successfully.
  • False. Did not add a method successfully.

It uses the following syntax:

AddMethod( "methodName", methodDef( argument, argument_n){
}, { methodConfig : value } );

where:

  • methodName is a string that contains the name of the method that Siebel Open UI adds to the presentation model.
  • methodDef is an argument that allows you to call a function or a function reference.
  • argument and argument_n are arguments that AddMethod sends to the method that methodDef identifies.
  • methodConfig is an argument that you set to one of the following values:
    • sequence. Set to one of the following values:
      • true. Siebel Open UI calls the method before it calls the function that already exists in the presentation model. This property loses meaning if you set the override property to true.
      • false. Siebel Open UI calls the method after it calls the function that already exists in the presentation model. The default value is false.
    • override. Set to one of the following values:
      • true. Siebel Open UI does not call the function that already exists in the presentation model. Instead, it calls the passed function, when necessary. Note that Siebel Open UI can never override some functions that exist in the predefined Presentational Model even if you set override to true.
      • false. Siebel Open UI calls the function that already exists in the presentation model.
    • scope. A string that describes the scope that Siebel Open UI must use when it calls the methodDef function. The default scope is Presentation Model.
Example of Adding a New Method

The following code adds a new ShowSelection method:

this.AddMethod( "ShowSelection", SelectionChange, { sequence : false, scope : this } );

After you add the ShowSelection method, you can use the following code to configure Siebel Open UI to call this method. It passes a string value of true to the sequence and a string value of blue to the scope argument:

this.ExecuteMethod( "ShowSelection", "true", "blue" );

Example of Using the Sequence Parameter

You can use the AddMethod method to get the feature of delegation interface of the function that is available in the predefined presentation model or that Siebel Open UI adds through the AddMethod method.

For example, the following code configures Siebel Open UI to attach a function. It calls this function anytime it calls the InvokeMethod method of the proxy:

this.AddMethod( "InvokeMethod", function(){
}, { sequence : true } );

This code sets the sequence parameter to true, which instructs Siebel Open UI to call the method that it passes before it calls the InvokeMethod method. The function that it passes gets all the parameters that the InvokeMethod method receives. For more information, see InvokeMethod Method.

Example of Overriding the Predefined Presentation Model

The following example overrides the predefined presentation model and runs the ProcessDrillDown method:

this.AddMethod( "ProcessDrillDown", function(){
}, { override : true } );

Other Examples

You can use the following code:

this.AddMethod( "InvokeMethod", function(){ console.log( "In Invoke Method of PM" ), { override: true });

this.AddMethod( "InvokeControlMethod", DerivedPresentationalModel.prototype.MyInvokeControlMethod, { sequence : true });

ExecuteMethod Method

The ExecuteMethod method runs a method. You must use ExecuteMethod to run any predefined or custom method that the presentation model contains. ExecuteMethod makes sure Siebel Open UI runs all injected dependency chains for the method that it calls. For more information, see About Dependency Injection.

If the method that ExecuteMethod specifies:

  • Exists. It returns a value from the method that it specifies.
  • Does not exist. It returns the following string:

    undefined

It uses the following syntax:

this.GetPM().ExecuteMethod( "methodName", arguments );

where:

  • methodName is a string that identifies the name of the method to call. You must use the AddMethod method to add the method that methodName specifies before you run ExecuteMethod. If the method that methodName specifies:
    • Exists. Siebel Open UI calls the method that the ExecuteMethod specifies, passes the arguments, gets the return value, and then passes this return value to the object that called the ExecuteMethod method.
    • Does not exist. The ExecuteMethod method does nothing.
  • arguments includes a list of one or more arguments where a comma separates each argument. ExecuteMethod passes these arguments to the method that methodName specifies. It passes these arguments in the same order that you list them in this argument list.
Example

The following example configures the predefined presentation model to use the InvokeMethod function. A physical renderer can get the value from the InvokeMethod function. EditPopup and inputPS are arguments of the InvokeMethod method:

this.GetPM().ExecuteMethod( "InvokeMethod", "EditPopup", inputPS );

AttachEventHandler Method

The AttachEventHandler method attaches an event handler for a physical event. It accepts the eventName and corresponding event handler that Siebel Open UI attaches to the Physical Event Arbitration layer. It returns one of the following values:

  • true. Attached a handler successfully.
  • false. Did not attach a handler successfully.

It uses the following syntax:

AttachEventHandler( "eventName", eventHandler());

where:

  • eventName is a string that identifies the name of the event that Siebel Open UI must attach to the Physical Event Arbitration layer.
  • eventHandler identifies the function that Siebel Open UI calls with a scope of Presentational Model.

You can use the AttachEventHandler method to override some of the predefined event handling. If you do this, then you must make sure it returns a value of False.

Using AttachEventHandler to Refresh Custom Events

Siebel Open UI does not come predefined to refresh a custom event. The example in this topic describes how to modify this behavior.

To use AttachEventHandler to refresh custom events

  1. Add the following code :

    this.AddMethod( "RefreshHandler", function( x, y, z ){
    // Add code here that does processing for RefreshHandler.
    });

    This code adds the RefreshHandler custom handler.

  2. Add the following code in the presentation model so that it is aware of the event that the RefreshEventHandler specifies:

    this.AttachEventHandler( "Refresh", "RefreshHandler" );

  3. Add the following code in the physical renderer:

    controlElement.bind( "click", { ctx: this}, function( event ){
    event.data.ctx.GetPM().OnControlEvent( "Refresh", value1, value2, value3);
    });

    This code binds the physical event to the presentational model.

Overriding an Event Handler

The example in this topic configures Siebel Open UI to override an event handler that the predefined presentation model references.

To override an event handler

  1. Configure Siebel Open UI to refresh a custom event.

    For more information, see Using AttachEventHandler to Refresh Custom Events.

  2. Add the following code:

    this.AddMethod( SiebelApp.Constants.get( "PHYEVENT_INVOKE_CONTROL" ), function( controlName ) {
    // Process Buttons Click
    return false;
    });

    This code configures Siebel Open UI to return the following value from the event handler. It makes sure this presentation model does not continue processing:

    false

OnControlEvent Method

The OnControlEvent method uses the following syntax:

OnControlEvent( eventName, eventArgs )

where:

  • eventName identifies the name of an event. You must use eventName to pass a physical event.

AttachPMBinding Method

The AttachPMBinding method binds a function to an existing function so that Siebel Open UI calls it when the existing function finishes processing. It returns one of the following values:

  • True. The bind succeeded.
  • False. The bind failed.

It uses the following syntax:

this.AttachPMBinding(
"methodName",
function(){ SiebelJS.Log( "methodBinder" );} ,
{ when : function(conditional_function){ return value; } } );

where:

  • methodName is a string that identifies the name of a method.
  • methodBinder identifies the function that Siebel Open UI calls when the function that the methodName parameter identifies finishes processing.
  • binderConfig identifies an object that specifies the properties for the function that the methodBinder parameter identifies.
  • binderConfig.scope identifies the object that Siebel Open UI uses to call the method that the methodBinder parameter identifies. The default value is Presentation Model.
  • conditional_function identifies a function that returns one of the following values. Siebel Open UI one of the following depending on this value:
    • true. Calls the AttachPMBinding method.
    • false. Does not call the AttachPMBinding method.
Example

The following example assumes the presentation model includes the FieldChange function. It configures Siebel Open UI to call another function when FieldChange finishes processing:

this.AttachPMBinding( "DoSomthing", function(){ SiebelJS.Log( "After DoSomething" ); } );

Conditionally Binding a Function

The example in this topic conditionally calls the AttachPMBinding method.

To conditionally bind a function

  • Add the following code:

    this.AttachPMBinding(
    "DoSomething",
    function(){ SiebelJS.Log( "After DoSomething" );} ,
    { when : function(function_name){ return false; } } );

    where:

    • function_name is a string that identifies the name of a function.

In this example, if Siebel Open UI calls DoSomething, then the presentation model calls the function_name that the when parameter specifies, and then tests the return value. If function_name returns a value of:

  • true. Siebel Open UI calls the AttachPMBinding method.
  • false. Siebel Open UI does not call the AttachPMBinding method.

If you do not include the when parameter, then Siebel Open UI runs the DoSomething method and then calls the AttachPMBinding method.

Binding Functions That Reside in the Physical Renderer

You can use the AttachPMBinding method to bind a function that resides in a physical renderer and that Siebel Open UI must call when the presentation model finishes processing. In this situation, you add the function reference in the physical renderer and you configure Siebel Open UI to pass the scope in the binderConfig parameter as a scope property.

AttachNotificationHandler Method

The AttachNotificationHandler method attaches a handler to the Presentational Model. It does this attachment when the notification occurs. It returns one of the following values:

  • True. Attached handler successfully.
  • False. Did not attach handler successfully.

It uses the following syntax:

this.AttachNotificationHandler("notification", function(propSet){

where:

  • notification is a string that includes the Notification Name where Siebel Open UI must do the sequencing.
  • handler identifies a that Siebel Open UI calls when Notification processing finishes.
  • notificationConfig identifies an object that contains properties for the Notification Binder function.
  • notificationConfig.scope identifies an object scope that Siebel Open UI uses when it calls the Notification Binder function. It defaults to the following value:

    Presentation Model

For example, the following code:

this.AttachNotificationHandler("g", function(propSet){

For more information, see Notifications That Siebel Open UI Supports.

AddComponentCommunication Method

The AddComponentCommunication method binds a communication method. It uses the following parameters:

  • methodName is a string that identifies the communication method that Siebel Open UI binds.
  • targetMethod a string that identifies the method that Siebel Open UI calls after the methodName finishes. It calls this target method in the presentation model context.
  • targetMethodConfig identifies an object that contains configuration properties for the targetMethod.
  • targetMethodConfig.scope identifies the object that the AddComponentCommunication method binds. This object must reference the targetMethod.
  • targetMethodConfig.args is a list of arguments that Siebel Open UI passes to the targetMethod when the AddComponentCommunication method runs.

AttachPreProxyExecuteBinding Method

The AttachPreProxyExecuteBinding method binds a function that resides in a proxy or presentation model to a Post Execute method. Siebel Open UI calls this function and then runs the Post Execute.

It uses the following syntax:

this.AttachPreProxyExecuteBinding( "binderName", function(handler, inputPS, outputPS){"binderConfig";
return;
});

where:

  • binderName is a string that identifies the method name where Siebel Open UI does the additional preprocessing.
  • handler identifies a function that Siebel Open UI calls when it calls Post Execute from the CallServer method. It runs this function before it runs Post Execute. For more information, see CallServer Method.
  • binderConfig is a string that identifies an object that specifies properties for the Post Execute Binder function.
  • binderConfig.scope identifies an object that specifies the scope that Siebel Open UI uses when it calls the Post Execute Binder function. The default value is Presentation Model.
Example

In this example, the user clicks the New button in an applet, Siebel Open UI runs the NewRecord method, runs the CallServer method, and then the client receives the reply from the Siebel Server. In this situation, you can use the following code to run some logic in the presentation model before Siebel Open UI runs the Post Execute method as part of the element life cycle:

this.AttachPreProxyExecuteBinding( "NewRecord", function(methodName, inputPS, outputPS){"Do Something for New Record";
return;
});

The following code runs this same logic in the presentation model for all methods:

this.AttachPreProxyExecuteBinding( "ALL", function(methodName, inputPS, outputPS){
"Do Something for all method";
return;
});

Using the AttachPreProxyExecuteBinding and AttachPostProxyExecuteBinding Methods

The AttachPreProxyExecuteBinding and AttachPostProxyExecuteBinding methods provide a more generic way to do more processing than the AttachNotificationHandler method provides before or after the proxy finishes processing the reply for a method that the client or the Siebel Server calls. A method might cause Siebel Open UI to create a notification from the Siebel Server that requires more post-processing than the client proxy requires. This situation can occur with a custom method that you implement on the Siebel Server. For example, for an applet, business service, or some other object type. Siebel Open UI sends a notification only for a typical modification that occurs in the predefined product. For example, a new or deleted record or a modified record set. A notification that Siebel Open UI sends after a typical Siebel Server operation or a business layer operation finishes is more granular. Siebel Open UI might not be able to identify and process the correct notification. For example, you can configure Siebel Open UI to call one WriteRecord method from the client, but the server business logic might cause this method to run multiple times. Siebel Open UI might receive notifications for any WriteRecord method that occurs for a business component that it binds to the current user interface. These notifications might contain more informaiton than the response notification that you must configure Siebel Open UI to process.

AttachPostProxyExecuteBinding Method

The AttachPostProxyExecuteBinding method binds a function that resides in a proxy or presentation model to a Post Execute method. Siebel Open UI runs the Post Execute function and then calls the AttachPostProxyExecuteBinding method.

It uses the following syntax:

this.AttachPostProxyExecuteBinding( "binderName", function(handler, inputPS, outputPS){"binderConfig";
return;
});

where:

  • binderName a string that identifies the method name where Siebel Open UI does the additional postprocessing.
  • handler identifies a function that Siebel Open UI calls when it calls the Post Execute from the CallServer method. It runs this function after it runs Post Execute. For more information, see CallServer Method.
  • binderConfig a string identifies an object that specifies properties for the Post Execute Binder function.
  • binderConfig.scope identifies an object that specifies the scope that Siebel Open UI uses when it calls the Post Execute Binder function. The default value is Presentation Model.

For more information, see Using AttachEventHandler to Refresh Custom Events.

Example

In this example, the user clicks the Delete button in an applet, Siebel Open UI runs the DeleteRecord method, runs the CallServer method, and then the client receives the reply from the Siebel Server. In this situation, you can use the following code to run some logic in the presentation model after Siebel Open UI runs the Post Execute method as part of the element life cycle:

this.AttachPostProxyExecuteBinding( "DeleteRecord", function(methodName, inputPS, outputPS){"Do Something for Delete Record";
return;
});

The following code runs this same logic in the presentation model for all methods:

this.AttachPostProxyExecuteBinding( "ALL", function(methodName, inputPS, outputPS){
"Do Something for all method";
return;
});

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