DocBook|Search
Class Reference
%ZEN.proxyObject
   
Server:basexml
Instance:SOAXML
User:UnknownUser
 
-
  [BASEXML] >  [%ZEN] >  [proxyObject]
Private  Storage  

class %ZEN.proxyObject extends %RegisteredObject

The Zen Proxy class provides a way to assemble data that can be conveniently passed between the web client and the server. It works in conjunction with the zenProxy JavaScript class defined in zenutils.js. The zenProxy class is the client-side representation of the server-side %ZEN.proxyObject class and vice versa.
The %ZEN.proxyObject class is useful for cases where you do not know what run-time properties will exist when you are designing your application (perhaps it is user-configurable).
The proxy class can be used in several ways. You can use it to send an arbitrary set of data values from the client to a server-side method. To do this, create an instance of zenProxy in a client-side JavaScript method:

	// create instance of zenProxy
	var obj = new zenProxy();
	obj.name = 'Smith';
	obj.code = 'CRM114';
The zenProxy object is basically a generic JavaScript object with a few pre-defined behaviors. You can dynamically add properties to it simply by setting them. These properties should have literal values, that is, they should not refer to other JavaScript objects.
If you define a server-side ZenMethod whose signature includes an argument of type %ZEN.proxyObject, then you can invoke this method from the client passing it an instance of a zenProxy object. Zen will automatically marshal the values in the zenProxy object into an instance of the %ZEN.proxyObject object.
For example, suppose you have defined a server method:
The client can invoke this method as it would any other Zen method, passing an instance of zenProxy as the pProxy argument:
	var obj = new zenProxy();
	obj.name = 'Smith';
	obj.code = 'CRM114';
	var ok = this.MyMethod(obj);
The MyMethod method will see the values 'Smith' and 'CRM114' for the properties name and code, respectively.
You can also use the %ZEN.proxyObject class to pass values from a server method back to the client. To do this, create a server method whose return type is %ZEN.proxyObject:
The client can invoke this method and use its return value as an object:
	var obj = this.getServerInfo();
	alert(obj.whatever);
The %ZEN.proxyObject does not actually define any properties. Instead it maintains an internal array of property names along with their corresponding values and uses dynamic dispatch to handle references to specific properties. This means that there is no name checking for properties of %ZEN.proxyObject (the same behavior as JavaScript objects). You can remove the current set of properties within a %ZEN.proxyObject object using the %Clear method. You can find out what the current set of properties is (as a local array) or supply a new set using the %CopyToArray and %CopyFromArray methods.
The client-side zenProxy class defines only one public method, clear, which deletes the current set of properties from the object. In all other ways, you can treat is an instance of JavaScript Object.
You can get the set of values within a %ZEN.Auxiliary.dataController objects using its getDataAsObject method.
When using the %ZEN.proxyObject class keep the following things in mind:

Inventory

Parameters Properties Methods Queries Indices ForeignKeys Triggers
11


Summary

Methods
%%OIDGet %AddToSaveSet %ClassIsLatestVersion %ClassName
%Clear %ConstructClone %CopyFromArray %CopyToArray
%DispatchClassMethod %DispatchGetModified %DispatchMethod %DispatchSetModified
%DispatchSetMultidimProperty %Extends %GetParameter %IsA
%IsModified %New %NormalizeObject %ObjectModified
%OriginalNamespace %PackageName %RemoveFromSaveSet %SerializeObject
%SetModified %ValidateObject


Methods

• final method %Clear()
Delete all properties and data currently in the proxy object.
• final method %CopyFromArray(ByRef pArray)
Copy the values from a local array (subscripted by property name) into this proxyObject.
• final method %CopyToArray(Output pArray)
Copy the properties in this proxyObject into a local array subscripted by property name.