pp108 : Instance

Instance

The Instance object holds the meta information required to fetch and manage data. The Model object holds the Instance object. Any model object should have an Instance object to communicate with the application service.
In order to retrieve data from the backend, each model should have an instance that stores the datasets and the namespace. In other words, each instance has a one-to-one relationship with the model.
The XML below describes the basic structure of an instance:

<xforms:instance wcpforms:receiver="..." wcpforms:iteratorSize="...">
<wcpforms:dataset src="..." type="..." />
<wcpforms:dataset src="..." type="..." />
</xforms:instance>

As seen from the above format definition, an instance can have one or more datasets, and each dataset has the name of the Web service operation and the namespace of the Web service operation in the following format:

http://<namespace of the operation>/<operation name>

For example, use 'http://schemas.cordys.com/1.0/demo/northwind/GetEmployees' to access the GetEmployees operation under the northwind Web service interface.
Process Platform XForms model supports three possible kinds of navigational models (Datasets). They are:

  • GET - This retrieves data using the specified Web service operation that satisfies a specified condition or a generic request.
  • NEXT - This retrieves the next set of business objects that are greater than a specified key value. The data depends on the cursor size set to the instance.
  • PREVIOUS - This retrieves the previous set of business objects that are less than or equal to a specified key value. The data depends on the cursor size set to the instance.

Note: The cursor (iterator) size can be set at design time using the Model Properties dialog box.
When navigational models are used, XForms adds the default values to the parameters depending on the data type. If the default values are not correct, you must correct them before sending a request.
The following instance denotes the model which has the GetEmployeeObject instance. It also has Next and Previous Web service operations that fetch data from Employees table based on the specific key - EmployeeID.

<xforms:model xmlns:xforms="http://www.w3.org/2002/xforms/cr" id="EmployeesModel">
<xforms:instance xmlns:wcpforms="http://schemas.cordys.com/wcp/xforms" wcpforms:iteratorSize="30">
<wcpforms:dataset src="http://schemas.cordys.com/1.0/employees/GetEmployeesObject" type="get">
<EmployeeID>1</EmployeeID>
</wcpforms:dataset>
<wcpforms:dataset src="http://schemas.cordys.com/1.0/employees/GetNextEmployeesObject" type="next">
<EmployeeID>1</EmployeeID>
</wcpforms:dataset>
<wcpforms:dataset src="http://schemas.cordys.com/1.0/employees/GetPreviousEmployeesObject" type="previous">
<EmployeeID>1</EmployeeID>
</wcpforms:dataset>
</xforms:instance>
</xforms:model>

In the above code the cursor (iteratorSize) size is set as 30 for the instance. This specifies that while using Next and Previous Web service operations, the data has to be retrieved in 30 tuples at a time.
The var newInstance = WebForm.getInstance([aIndexKeysArray], [sUpdateNamespace], sBusinessObjectName, oApplication ) script is used for creating an instance. In which,

  • aIndexKeysArray is optional. This is the array that denotes the list of parameters for the Web service operation. This is used for finding a business object.
  • sUpdateNamespace is an optional string. It denotes the namespace of the Web service operation that is used to synchronize the business object with the backend.
  • sBusinessObjectName is a string that denotes the business object's name.
  • oApplication is an object that denotes the current application.

To create an Employee object instance with 'http://schemas.cordys.com/employees:' as namespace, use var newInstance = WebForm.getInstance(new Array("EmployeeID"), "http://schemas.cordys.com/employees", "Employees", application).
When a model is created, the created instance object is passed as a parameter.

Properties and Methods of the Instance Object

The properties and methods associated with the Instance object define its behavior.

Table 1. List of Properties

Runtime property

Description

businessObjectName

Sets or retrieves the name of the root XML data node (Business Object ) that a data model represents. This will be used when inserting new data into the model's dataset.

updateNamespace

Sets or retrieves the namespace URL of the Update method that is used to synchronize the data in the model's dataset with the server.

Table 2. List of Methods

Method

Description

setReceiver(sReceiver)

This method sets the receiver property of the Instance object.

setTimeout(iTimeout)

This method sets the timeout duration that denotes the time for which the Web server should wait for a response.

Related reference

getInstance()
getModel()
Model
Non-transactional - nontransactional (Model)
Instance
Receiver
setReceiver()