pp108 : getModel()

getModel()


Creates a model object in the current form. A model can be created at runtime only when an instance is available.

Syntax

Script

oModel = WebForm.getModel(oInstance, sModelName, aEvents, bNontransactional)


Parameters

Parameter

Description

oInstance

Object that denotes the instance for the model.

sModelName

String that denotes the name of the model.

aEvents

Array that denotes the events that are set for the model. This is a two dimensional array containing the event name and handler name.

bNontransactional

It is a boolean denoting whether the model is non-transactional or not. When a model is non-transactional, then the data will be kept for display purposes, and synchronization with the application service will not happen by default. Also,<tuple><old>format is not mandatory for non-transactional data.


Return Value


Returns the object that denotes the model created for the instance.

Remarks


A model contains the data fetched from the application service.
There are three kinds of request which a model can make to application service. They are the requests for:

  • getting first and next datasets.
  • getting last or previous datasets.
  • getting the exact (or similar) data sets.

    A model can be transactional or non-transactional. Transactional models require the<tuple><old>format for the data and they handle the default synchronization of the modified dataset with the application service. While a non-transactional model does not require a<tuple><old> format, synchronization of data with the application service is not done by default and the developer has to update the data.

    Once a model is created at runtime, the controls that need to get the data from the model should be registered to the model.

Example

This sample code demonstrates how the method can be used.

var employeesIndex = new Array("EmployeeID", "ReportsTo");
var employeesNamespace = "http://schemas.cordys.com/Employees";
//Create new instance
var newInstance = WebForm.getInstance(employeesIndex, employeesNamespace, "Employees", application);
//Create an event and handler for model's xforms-insert
var newModelHandler = new Array();
newModelHandler["xforms_insert"][0] = insertHandler;

Applies to


WebForm

Related reference

Instance
getInstance()
Model
Non-transactional - nontransactional (Model)