Text Copy of the Client Control Presentation Model File

The following code from the clientctrlpmodel.js file adds example controls to the client. You can examine this code for your reference. To get a copy of this file, see Article ID 1494998.1 on My Oracle Support:

if( typeof( SiebelAppFacade.ClientCtrlPModel ) === "undefined" ){   
  SiebelJS.Namespace( 'SiebelAppFacade.ClientCtrlPModel' );   
  //Module with its dependencies   
  define("siebel/custom/clientctrlpmodel", [], function () {   
  SiebelAppFacade.ClientCtrlPModel = ( function(){   
    var consts  = SiebelJS.Dependency( "SiebelApp.Constants" );    
    /* *   
    * Constructor Function - ClientCtrlPModel   
    *   
    * Parameter - Be a good citizen. Pass All parameter to superclass.    
    * */   
    function ClientCtrlPModel(proxy){   
      var m_recordset = [];   
      SiebelAppFacade.ClientCtrlPModel.superclass.constructor.call( this, proxy);   
      this.AddMethod( "AddClientControl", null, { core : true } );       
      // add into method array   
      this.GetClientRecordSet = function( ) {   
        return m_recordset ;   
      };   
    }   
    /* Siebel OpenUI uses the ListPresentationModel object to initialize every list 
applet. So, to maintain the functionality that ListPresentationModel provides, you 
extend it.*/   
    SiebelJS.Extend( ClientCtrlPModel, SiebelAppFacade.ListPresentationModel );   
    ClientCtrlPModel.prototype.Init = function(){   
      SiebelAppFacade.ClientCtrlPModel.superclass.Init.call( this );   
      /* Attach Post Handler for LeaveField */   
      this.AddMethod( "LeaveField", PostLeaveField, { sequence : false, scope : this 
} );   
      /* Attach Pre Handler for GetFormattedFieldValue */   
      this.AddMethod("GetFormattedFieldValue", PreGetFormattedFieldValue, { sequence 
: true, scope : this } );   
      /* Attach Handler for Delete Record Notification as well */   
      this.AttachNotificationHandler( consts.get( "SWE_PROP_BC_NOTI_DELETE_RECORD" 
),       HandleDeleteNotification );   
    };   
    function PreGetFormattedFieldValue(control, bUseWS, recIndex, returnStructure){   
      if (utils.IsEmpty(recIndex)){   
        recIndex = this.Get("GetSelection");   
      }   
      if (recIndex >=0) {   
        var clientObj = this.GetClientRecordSet();   
        var recordSet=this.Get("GetRawRecordSet");   
        var id = recordSet[recIndex]["Id"];   
        var flag = false;   
        var value;   
        switch(control.GetName()){   
          case "TestEdit":   
            value = recordSet[recIndex]["Name"];   
            flag = true;   
            break;   
        }   
        if (flag){   
          if( clientObj[id] && clientObj[id][control.GetName()] ){   
            value = clientObj[id][control.GetName()];   
          }   
          else if (clientObj[id]){   
            clientObj[id ][control.GetName()] = value;   
          }   
        else{   
            var recordclient = {};   
            recordclient[control.GetName()] = value;   
            clientObj[id] = recordclient;   
          }   
          returnStructure[ "CancelOperation" ] = true;   
          returnStructure[ "ReturnValue" ]     = value;   
        }   
      }   
    }   
    function PostLeaveField( control, value, notLeave, returnStructure ){   
      var clientObj = this.GetClientRecordSet();   
      var currSel = this.Get( "GetSelection" );   
      var recordSet=this.Get("GetRawRecordSet");   
      var id = recordSet[currSel]["Id"];   
      if (clientObj[id]){   
        switch(control.GetName()){   
          case "TestEdit":   
            clientObj[id][control.GetName()] = returnStructure[ "ReturnValue" ] ;    
            break;   
        }   
      }   
    }   
        function HandleDeleteNotification(propSet){   
          var activeRow = propSet.GetProperty( consts.get( 
"SWE_PROP_BC_NOTI_ACTIVE_ROW" ) );   
          if( activeRow  === this.Get( "GetSelection" ) ){   
            var delObj = this.GetClientRecordSet();   
            delObj[ activeRow ] = null;   
          }   
        }   
        ClientCtrlPModel.prototype.UpdateModel = function(psInfo){   
        /// PS Attribute info for Edit box   
        SiebelAppFacade.ClientCtrlPModel.superclass.UpdateModel.call( this, psInfo );   
        var ctrlTxtInfo = SiebelAppFacade.PresentationModel.GetCtrlTemplate 
("TestEdit", "Test Edit", consts.get( "SWE_CTRL_TEXTAREA" ), 1);   
      this.ExecuteMethod( "AddClientControl", ctrlTxtInfo );   
    };   
    return ClientCtrlPModel;   
  } ());   
    return "SiebelAppFacade.ClientCtrlPModel";   
  });   
}