DataObject

Base class of all record-like data objects in a dataset.

Remarks

This class contains support for "active objects", which have an ID_aref property and communicate back with the server when they change.

Methods

addEventHandler (inherited from SitedObject)Adds a delegate to be called when the specified eventId occurs on this object.
equals (inherited from SitedObject)Tests if two objects are equal.
fireEventHandler (inherited from SitedObject)Invokes any user event handlers registered for a particular event using SitedObject.addEventHandler().
getArefGets the "active reference" for this object
getBindingStatus (inherited from SitedObject)Provides debugging information on bindings for this object.
getDataSetAndPathGets the dataset and aref path of this object.
getPathValue (inherited from SitedObject)Traverses a binding path and returns the value at the end of it.
getPropertyInfo (inherited from SitedObject)Gets information on a property.
getPropertyKeysInUseReturns an array of the non-null public property keys currently set on this object.
getSite (inherited from SitedObject)Gets this object's site.
getValue (inherited from SitedObject)Gets the value of a property on this object.
marshallToJsonMarshall JavaScript objects into a JavaScript Object Notation string.
onSetValue(Override) Called by SitedObject.setValue() when a property value is set on this object.
onSited (inherited from SitedObject)Called when this object is sited.
onUnsited (inherited from SitedObject)Called when this object is about to lose its site.
onValueSited (inherited from SitedObject)Called when an object is sited within this object.
onValueUnsited (inherited from SitedObject)Called when an object is about to be unsited in this.
removeEventHandler (inherited from SitedObject)Remove an existing delegate from the list of delegates for the specified event.
resetPublicPropertiesResets simple public properties to their default values
setInitialValues (inherited from SitedObject)Sets multiple property values on an object (during initialization only)
setPathValue (inherited from SitedObject)Traverses a binding path and sets the value at the end of it.
setValue (inherited from SitedObject)Sets the value of a property on this object.
toString (inherited from SitedObject)Returns a string representation of this object.

DataObject getAref method

Gets the "active reference" for this object

JavaScript

var strVal = dataObject.getAref()

Remarks

If this is an "active" DataObject, i.e. if this object is connected to live data on the server, then getAref returns an opaque id used by the server to uniquely identify this object. If this is a static object (i.e. a dataobject that didn't come from a database), getAref return null.

Returns

A string, or null if this object has no active reference.

DataObject getDataSetAndPath method

Gets the dataset and aref path of this object.

JavaScript

var dataSet = dataObject.getDataSetAndPath(pathArray)

Remarks

This gets the dataset the object belongs to, and also fills in pathArray with a set of string "arefs" describing how to navigate from the dataset to this data object.

Returns

A DataSet, or null if this object is currently not in a data set.

Example

If this object has an ID_aref property of "obj_1", and it is in a dataset called "items", then:

var pathArray = new Array();
var dataSet = obj.getDataSetAndPath(pathArray);

sets dataSet to point to the obj's DataSet, and add two strings to path array: "items" (the name of the dataset) and "obj_1" (the aref of obj).

See Also

DataObject getPropertyKeysInUse method

Returns an array of the non-null public property keys currently set on this object.

JavaScript

dataObject.getPropertyKeysInUse()

Remarks

Each DataObject has a list of public properties that it defines. This returns a subset of that list that currently have non-null values.

DataObject marshallToJson static method

Marshall JavaScript objects into a JavaScript Object Notation string.

JavaScript

DataObject.marshallToJson(obj)

Remarks

This takes a JavaScript object hierarchy containing arrays/strings/nested objects. It serializes this to a JSON style string. NB. This doesn't handle circular graphs of objects.

DataObject onSetValue method (override)

Called by SitedObject.setValue() when a property value is set on this object.

JavaScript

dataObject.onSetValue(propertyId,oldVal,newVal,notificationSource)

Remarks

This calls DataSet.sendCommand() to send a "set" command back to the server to update server-side values for properties on this DataObject when they change.

Base Implementation

DataObject resetPublicProperties method

Resets simple public properties to their default values

JavaScript

dataObject.resetPublicProperties()

Remarks

For each simple public property of this data object, this sets the value of that property to '' for string properties, 0 for numeric properties, and false for boolean properties. Compound properties (e.g. lists or nested objects) are left as null.