putData() |
It assigns the specified data to the model. This method can be used when the specified data has to be appended to the existing data of the model or assigned to the model by clearing the existing data in the model.
This methos fires theondatacompleted|xforms-ondatacompleted|event.
Syntax
Script | modelID.putData(oData[, bRefreshRenderer][,sSearchPath][,bClearData]) |
Parameters
Parameter | Description |
---|---|
oData | Object that denotes the data that is to be set to the model. For non-transactional models, this parameter does not support collections. |
bRefreshRenderer | This is an optional parameter. It take boolean that denotes whether the views of the model should be refreshed once data is set to the model.
|
sSearchPath | This is an optional parameter. String that denotes the XPath of the node in the oData XML object to which the view of the model will be bound. This search path should contain the path of the root element of the data to which the view should be bound. By default, ifSOAP:Envelope, SOAP:Body, anddatasetordatanodes are present in the oData object, they will be considered as the root element for binding the views associated with the model. However, this parameter is not considered if the oData object is a collection. |
bClearData | This is an optional parameter. It takes boolean value that denotes whether the existing data in the model has to be cleared before the supplied data is assigned to the model.
|
Return Value
No value is returned.
Remarks
This method can be used when the data is as a result of some other page's model, or is of the non-transactional origin or a case where the data is a combination of one or more data sets. When merging the new data with the old data in the model, the new data is not validated against the business object of the existing data.
In case of a non-transactional models, the new data that gets added can be appended to the one that already exists, by setting the bClearData parameter to false. By default, any data in the putData() method overwrites the existing data.
Example
This sample code demonstrates how the method can be used.
//Create instance and model var newInstance = WebForm.getInstance("", "http://schemas.cordys.com/Employees", "Employees", application); var newModel = WebForm.getModel(newInstance, "DummyModel"); //Get data from some other model. Assume Employees Model is associated with GetEmployeesObjects method and has data in it. var data = Employeesmodel.getData(); //Refresh the component as well while setting data newModel.putData(data, true);