%ZEN.proxyObject
class %ZEN.proxyObject extends %Library.RegisteredObject [ Final ]
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';
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:
ClassMethod MyMethod(pProxy as %ZEN.proxyObject) As %Boolean [ZenMethod] { Set tName = pProxy.name Set tCode = pProxy.code Quit 1 }
var obj = new zenProxy(); obj.name = 'Smith'; obj.code = 'CRM114'; var ok = this.MyMethod(obj);
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:
ClassMethod GetServerInfo() As %ZEN.proxyObject [ZenMethod] { Set tProxy = ##class(%ZEN.proxyObject).%New() Set tProxy.whatever = "Some server value" Quit tProxy }
var obj = this.GetServerInfo(); alert(obj.whatever);
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:
- All properties must have literal values (numbers or strings).
- You have to use property names that are valid in both the client and server environments. This means that names have to agree in case. It also means that you cannot have two properties with the same name but different case.
Set myProperty = tProxy."my_property" Set tProxy."$$foo" = "bar"
Method Inventory
- %Clear()
- %CopyFromArray()
- %CopyToArray()
- DeleteDocument()
- DocumentExists()
- OpenDocument()
- OpenEmbeddedDocument()
- SaveDocument()
Methods
Parameters | ||
---|---|---|
pWhere | Input |
Global or local variable reference. This is the location from where the proxyObject instance will be deleted. |
pDocumentID | Input |
The document ID. |
Parameters | ||
---|---|---|
pWhere | Input |
Global or local variable reference where documents are stored. |
pDocumentID | Input |
The document ID. |
Parameters | ||
---|---|---|
pWhere | Input |
Global or local variable reference. This is the location where the proxyObject instance will be saved. |
pDocumentID | Input |
The ID of the document to be opened. |
pStatus | Output |
The returned %Status value, indicating success or failure. |
Parameters | ||
---|---|---|
pWhere | Input |
Global or local variable reference. This is the location where the proxyObject instance will be saved. |
pDocumentID | Input |
The ID of the document containing the embedded document. |
pObjectID | Input |
The objectID of the document embedded in the specified pDocumentID. |
pStatus | Output |
The returned %Status value, indicating success or failure. |
Parameters | ||
---|---|---|
pWhere | Input |
Global or local variable reference. This is the location where the proxyObject instance will be saved. |
pDocumentID | Input |
The document ID. This value must be unique within the GLVN specified in pWhere. |
Inherited Members
Inherited Methods
- %AddToSaveSet()
- %ClassIsLatestVersion()
- %ClassName()
- %ConstructClone()
- %DispatchClassMethod()
- %DispatchGetModified()
- %DispatchMethod()
- %DispatchSetModified()
- %DispatchSetMultidimProperty()
- %Extends()
- %GetParameter()
- %IsA()
- %IsModified()
- %New()
- %NormalizeObject()
- %ObjectModified()
- %OriginalNamespace()
- %PackageName()
- %RemoveFromSaveSet()
- %SerializeObject()
- %SetModified()
- %ValidateObject()