pp108 : registerAssociatedModel()

registerAssociatedModel()


It associates the supplied model with the current model.

Syntax

Script

modelID.registerAssociatedModel (oAssociatedModel, oRefArray);


Parameters

Parameter

Description

oAssociatedModel

Object. Denotes the model object that will be registered as an associated model with the current model

oRefArray

Array. Denotes the array that contains the list of parameters that is required for the associated model's requests. This is the mapping that makes the association between the models effective.


Return Value


No value is returned.

Remarks


If a model is associated to another model, it means that the child model depends on the data of the parent model for its requests.

The parameters for the request of the child model will be taken from the active business object of the parent model. This mapping is provided by the oRefArray parameter.

For example, consider the following scenario.

The child model's request (Get or Next) has the input parameters:cParam1andcParam

2. The response of the parent model has the pParam1 and pParam
2. elements.

Now consider a case in which the values of the elementspParam1andpParam2should be passed to the child model's parameterscParam1andcParam2respectively. Hence, the oRefArray should be defined as:

var oRefArray = new Array();
oRefArray["cParam1"] = pParam1;
oRefArray["cParam2"] = pParam2;


Now the link between the child and parent model is established through this oRefArray .

When the active business object of the parent model is changed, then the associated (child) model sends its default request with the values of this current business object.

A parent model can have more than one model as its children but a child model cannot be associated with more than one parent model.

Example

The following example shows how this method can be used.

// Example - Association between EmployeesModel and ReportsToModel
   // EmployeesModel is the Parent Model. It has the method GetEmployeesObjects. 
   // A table is attached to this model.
   // ReportsToModel is the Child Model. It has the method GetEmployeeObject. 
   //  A groupbox with two input controls (with reference set as EmployeeID 
   // and FirstName) is attached to this model.
   // The value of the "ReportsTo" Field of the active business object 
   // corresponding to EmployeesModel is passed as the 
   // "EmployeeID" parameter for the Get Method of ReportsToModel.
   var oParameters = new Array();
   oParameters["EmployeeID"] = "ReportsTo";
   EmployeesModel.registerAssociatedModel(ReportsToModel,oParameters); 
   EmployeesModel.reset();

Applies to


Model

Related reference

Parent Model