pp108 : putData()

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.

  • True- Refreshes the views registered to the model.
  • false- Default. Sets the data without refreshing the views registered to 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.

  • True: Model's data will be cleared and new data is put into that. This is the default value if the model is non-transactional.
  • False: Default. This is the default value if the model is transactional. The following are the possible scenarios:If there is a modified tuple, that is if a tuple in the oData object has the sync_id attribute set, then the tuple with the same sync ID in the existing data set will be searched for and, if available, the existing tuple will be replaced with the one in the oData object. If the tuples in the oData object does not have a sync_id attribute, those tuples will be directly appended to the existing dataset. Databinding depends on the xql in the new tuples. All the views of the model will be redrawn with the new data.


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);

Applies to


Model

Related reference

Setting Data For Models
Model