IRISLIB database
altJSONProvider Class Reference

The jsonProvider component provides a way to transport object data between a server and client (and vice versa) using JavaScript Object Notation (commonly abbreviated as JSON), as defined in RFC4627. More...

Inheritance diagram for altJSONProvider:
Collaboration diagram for altJSONProvider:

Public Member Functions

 getContentObject ()
 Return the client-side JSON data as an object or null.
 
 getContentType ()
 Return the type of the data supplied by this provider: "object" or "array".
 
 getData (d1, d2, d3)
 dataSet API
More...
 
 getDataAsArrays ()
 This is a specialized variant of <method>getData</method>() that. More...
 
 getDataSourceCaption (which, text)
 Return a title to display for this data source. More...
 
 getDimSize (dim)
 Return the number of items in the specified dimension. More...
 
 getError ()
 Get the current value of the <property>error</property> property. More...
 
 getLabel (n, dim)
 Get the label at position n (0-based) in the given. More...
 
 getPropertyName (n)
 Given a 0-based index, return the corresponding property name.
 
 hasData ()
 Return true if this controller currently contains data.
 
 onloadHandler ()
 This client event, if present, is fired when the page is loaded.
 
 refreshContent ()
 Deprecated: use <method>reloadContents</method>().
 
 reloadContents ()
 Reload the contents of the provider with data from the server. More...
 
 reloadContentsAsynch (notify, time)
 Reload the contents of the json provider asynchronously;. More...
 
 save ()
 Save data from this dataController back to the DataModel on the server. More...
 
 setContentObject (obj)
 Make obj the new target object for this provider.
 
 setContentText (json)
 Set the content for this provider using the string json. More...
 
 setContentType (type)
 Set the type of the data supplied by this provider: "object" or "array".
 
 submitContent (command, targetClass, notify, time)
 Send the current target object for this provider to the server. More...
 
- Public Member Functions inherited from abstractController
_.Library.Status OnNew (_.Library.RawString initvalue)
 Constructor for Zen objects. More...
 
 createNewObject ()
 Ask our associated dataModel to create a new (unsaved) instance.
 
 deleteId (id)
 Ask our associated dataModel to delete the item with the given id. More...
 
 getDataAsObject (series)
 This is a specialized variant of <method>getData</method> that. More...
 
 getDataByName (property, series)
 dataBag API More...
 
 getDimensions ()
 dataSet API More...
 
 getModelId ()
 Return the current model id associated with this dataController.
 
 getTypeByName (property)
 Get the type code for a property given its name.
 
 invokeAction (action, data)
 Invoke a named action on our associated dataModel. More...
 
 isModelReadOnly ()
 Test if the current data model is read-only.
 
 isPropertyValid (property, value)
 Test if a given value for a property is valid.
 
 onDelete ()
 This client method, if present, is called when this component is. More...
 
 raiseDataChange ()
 Send notification to listeners that the data associated with this dataController has. More...
 
 sendEventToViews (reason, source, data1, data2, data3)
 Send an event to all listeners (dataViews) connected to this dataController. More...
 
 setData (value, d1, d2, d3)
 dataSet API More...
 
 setDataByName (property, value, series)
 dataBag API More...
 
 setModelId (id)
 Set the value of the <property>modelId</property> property for this controller. More...
 
 setProperty (property, value, value2)
 Set the value of a named property.
 
 update ()
 Reload the data in the dataController from the server.
 
- Public Member Functions inherited from component
 dragFinishHandler (dragData)
 This is called when a drag operation started within this component. More...
 
 dragHandler ()
 This is called by the layout manager when a drag-and-drop operation. More...
 
 dragNotifyHandler (dragData)
 This is called by the layout manager when a drag operation. More...
 
 dragStartHandler (dragData)
 This is called when a drag operation is started within this component. More...
 
 dropHandler ()
 This is called by the layout manager when a drag-and-drop operation. More...
 
 dropStartHandler (dragData)
 This is called when a data drop operation is started within this component. More...
 
 exposeComponent ()
 This manages the ondisplay event callback handling. More...
 
 getEnclosingDiv ()
 Client-side method returns the div element that encloses. More...
 
_.Library.String getHidden ()
 Return whether this component is hidden.
 
 getHintElement ()
 Client-side method returns the HTML element that displays. More...
 
 getLabelElement ()
 Client-side method returns the HTML element that displays. More...
 
 onDisplayHandler ()
 This client callback is called from exposeComponent after. More...
 
 onEndModalHandler (zindex)
 Notification that this component is about to stop being modal.
 
 onPopupAction (popupName, action, value)
 This client event, if present, is fired when a popup page has specified. More...
 
 onRefreshContents ()
 This client callback is called just from refreshContents. More...
 
 onStartModalHandler (zindex)
 Notification that this component is about to become modal. More...
 
 refreshContents (sync)
 This method, called from a client page, invokes this component's. More...
 
 setHidden (flag)
 If flag is true, hide this component. More...
 
 setOverlayMode (mode)
 Expirimental: do not use. More...
 
 startProgressBar (div)
 Start the display of a progress bar within display. More...
 
 stopProgressBar ()
 Stop the timer used by the Progress bar.
 
- Public Member Functions inherited from object
 findElement (subid)
 Client-side utility method that finds an HTML element with a. More...
 
 fireOnUpdateEvent ()
 This is called when an object is updated from the server. More...
 
_.Library.String getProperty (property, key)
 Return the value of a named property (i.e. More...
 
 getSettings (settings)
 Client-side method that returns a list of this component's. More...
 
 getType ()
 Returns the component type of this object. More...
 
 invokeSuper (method, args)
 Invoke the superclass method method of the current. More...
 
 isOfType (type)
 Returns true if this object is of the given component type. More...
 
 makeId (subid)
 client-side utility method that constructs a component-specific id More...
 
 onCreate ()
 This client method, if present, is called when this component is. More...
 
 onSerialize ()
 This client event, if present, is fired before a component. More...
 
 onunloadHandler ()
 This client event, if present, is fired when the page is unloaded. More...
 
 onupdateHandler ()
 This client method, if present, is fired when the object is updated from the server.
 
 render ()
 This causes a component that draws its contents dynamically. More...
 
 renderContents ()
 This method, if present, is called when this component. More...
 
 renderSVG (document, parent)
 This method is only needed for SVG components. More...
 
- Public Member Functions inherited from RegisteredObject
_.Library.Status OnAddToSaveSet (_.Library.Integer depth, _.Library.Integer insert, _.Library.Integer callcount)
 This callback method is invoked when the current object is added to the SaveSet,. More...
 
_.Library.Status OnClose ()
 This callback method is invoked by the <METHOD>Close</METHOD> method to. More...
 
_.Library.Status OnConstructClone (_.Library.RegisteredObject object, _.Library.Boolean deep, _.Library.String cloned)
 This callback method is invoked by the <METHOD>ConstructClone</METHOD> method to. More...
 
_.Library.Status OnNew ()
 This callback method is invoked by the <METHOD>New</METHOD> method to. More...
 
_.Library.Status OnValidateObject ()
 This callback method is invoked by the <METHOD>ValidateObject</METHOD> method to. More...
 
- Public Member Functions inherited from Adaptor
_.Library.Status XMLExport (_.Library.String top, _.Library.String format, _.XML.Namespaces namespaces, attrs, _.Library.String createId, _.Library.String typeAttr, oreflist, idlist, _.Library.String initialIndent, _.Library.Boolean local, _.Net.MIMEPart mimeAttachments)
 Serialize an XML enabled class as an XML document and write. More...
 
_.Library.Status XMLExportToStream (_.Stream.Object export, _.Library.String top, _.Library.String format, _.XML.Namespaces namespaces, attrs, _.Library.String createId, _.Library.String typeAttr, oreflist, idlist, _.Library.String initialIndent)
 Serialize an XML enabled class as an XML document and appends it to a stream. More...
 
_.Library.Status XMLExportToString (_.Library.String export, _.Library.String top, _.Library.String format, _.XML.Namespaces namespaces, attrs, _.Library.String createId, _.Library.String typeAttr, oreflist, idlist, _.Library.String initialIndent)
 Serialize an XML enabled class as an XML document and write it to a string. More...
 

Public Attributes

 OnGetArray
 Supply data for the JSON provider as a server-side array. More...
 
 OnGetTargetObject
 Supply data for the JSON provider as a set of server objects. More...
 
 OnRenderJSON
 Optional. More...
 
 OnSubmitContent
 This callback method is invoked when the client submits an object to the. More...
 
 documentId
 Optional. More...
 
 error
 Run-time value. More...
 
 parameters
 User-defined set of parameters. More...
 
 propertyList
 Optional. More...
 
 seriesNameProperty
 Optional. More...
 
 targetClass
 Class name of the target object expected to be served by this component. More...
 
- Public Attributes inherited from abstractController
 alertOnError
 @qualifier final If true (the default), then the dataController will display an alert More...
 
 autoRefresh
 @qualifier final Setting this to a non-zero value will turn on autoRefresh mode More...
 
 defaultSeries
 @qualifier final Optional. More...
 
 modelError
 @qualifier final Most recent error message reported by the DataModel object this More...
 
 modelId
 @qualifier final ID value passed to the DataModel class. More...
 
 oncreate
 @qualifier final oncreate event handler: More...
 
 ondelete
 @qualifier final ondelete event handler: More...
 
 onerror
 @qualifier final onerror event handler: More...
 
 onnotifyController
 @qualifier final onnotifyController event handler: More...
 
 onsave
 @qualifier final onsave event handler: More...
 
 readOnly
 @qualifier final If true, this data controller is read only regardless of whether its More...
 
- Public Attributes inherited from component
 align
 Specifies how this component should be horizontally aligned within its layout cell. More...
 
 containerStyle
 CSS style applied to the td element used to contain this child component within. More...
 
 dragEnabled
 If this value is true and dragAndDrop is enabled for the page, then. More...
 
 dropEnabled
 If this value is true and dragAndDrop is enabled for the page, then. More...
 
 enclosingClass
 Optional CSS class used for this component's enclosing div. More...
 
 enclosingStyle
 Optional CSS style applied to this component's enclosing div. More...
 
 error
 Run-time value; Set to indicate an error within this component. More...
 
 height
 Specifies the height of this component with respect to its container. More...
 
 hidden
 If true, this component is hidden. More...
 
 hint
 User defined hint text used to display additional hint text for this component. More...
 
 hintClass
 Optional CSS class used for the component hint. More...
 
 hintStyle
 User defined style used for the component hint. More...
 
 label
 User defined label used to label this component. More...
 
 labelClass
 Optional CSS class used for the component label. More...
 
 labelDisabledClass
 Optional CSS class used for the component label when disabled. More...
 
 labelStyle
 User defined style used for the component label. More...
 
 onafterdrag
 onafterdrag event handler: More...
 
 onbeforedrag
 onbeforedrag event handler: More...
 
 ondrag
 ondrag event handler: More...
 
 ondrop
 ondrop event handler: More...
 
 onhide
 onhide event handler: More...
 
 onrefresh
 onrefresh event handler: More...
 
 onshow
 onshow event handler: More...
 
 showLabel
 Controls whether a label is displayed for this component. More...
 
 slice
 User-defined number of units of relative space this. More...
 
 title
 Help text (tool tip) displayed when mouse hovers over this component (or its label). More...
 
 valign
 Specifies how this component should be vertically aligned within its layout cell. More...
 
 width
 Specifies the width of this component with respect to its container. More...
 
- Public Attributes inherited from object
 aux
 @qualifier final This is an auxiliary property that is provided More...
 
 composite
 @qualifier final For components that are created as part of a composite component, More...
 
 id
 @qualifier final This is a unique identifier that is used to distinguish this object More...
 
 index
 @qualifier final System-assigned index number used internally to identify this component. More...
 
 name
 @qualifier final Name of this object. More...
 
 onupdate
 onupdate event handler: More...
 
 parent
 @qualifier final Link to the component that contains this object More...
 
 tuple
 @qualifier final Special property indicating which tuple of a More...
 
 visible
 This property indicates whether a component is visible and thus layed out. More...
 
 window
 @qualifier final This is a client-only property that refers to the JavaScript More...
 

Static Public Attributes

 DEFAULTVISIBLE = None
 This component is not visible.
 
- Static Public Attributes inherited from abstractController
 DEFAULTVISIBLE = None
 This component is not visible.
 
- Static Public Attributes inherited from component
 DEFAULTENCLOSINGCLASS = None
 Subclasses can set this to change default enclosingClass used for this. More...
 
 DEFAULTHEIGHT = None
 Subclasses can set this to change default height for a component.
 
 DEFAULTHIDDEN = None
 Subclasses can set this to change default hidden property for a component.
 
 DEFAULTHINTCLASS = None
 Subclasses can set this to change default css class used for hints.
 
 DEFAULTLABELCLASS = None
 Subclasses can set this to change default css class used for labels.
 
 DEFAULTLABELDISABLEDCLASS = None
 Subclasses can set this to change default css class used for disabled labels.
 
 DEFAULTVISIBLE = None
 Subclasses can set this to change default visibilty for a component.
 
 DEFAULTWIDTH = None
 Subclasses can set this to change default width for a component.
 
- Static Public Attributes inherited from object
 DEFAULTVISIBLE = None
 Subclasses can set this to change default visibilty for a component.
 
 INCLUDEFILES = None
 CSV list of additional include files (either .js or .css) that. More...
 
 MODULE = None
 If set, this indicates that this system component should be. More...
 
 NAMESPACE = None
 This is the XML namespace used for library components.
 
 POSTCOMPILEACTIONS = None
 This is a comma-delimited list of which post-compile actions this component. More...
 
 USECOMMONDIRECTORY = None
 If true, then the include files generated for this component, are placed in the. More...
 
 XMLFORMAT = None
 If XMLFORMAT="Literal", then only support for literal format import and export is generated. More...
 
 XMLIGNOREINVALIDATTRIBUTE = None
 By setting this to 0, we disallow use of invalid attribute names in Zen XML documents.
 
- Static Public Attributes inherited from RegisteredObject
 CAPTION = None
 Optional name used by the Form Wizard for a class when generating forms. More...
 
 JAVATYPE = None
 The Java type to be used when exported.
 
 PROPERTYVALIDATION = None
 This parameter controls the default validation behavior for the object. More...
 
- Static Public Attributes inherited from Adaptor
 ATTRIBUTEQUALIFIED = None
 ATTRIBUTEQUALIFIED controls the format of exported XML by controlling whether attributes. More...
 
 ELEMENTQUALIFIED = None
 ELEMENTQUALIFIED controls the format of exported XML. More...
 
 NAMESPACE = None
 NAMESPACE specifies the XML namespace to be used when projecting the. More...
 
 SUPPRESSTYPEPREFIX = None
 SUPPRESSTYPEPREFIX allows the type name that refers to this class. More...
 
 XMLDEFAULTREFERENCE = None
 XMLDEFAULTREFERENCE specifies the default value of the XMLREFERENCE property parameter. More...
 
 XMLENABLED = None
 If this parameter is true then XML-enabling methods. More...
 
 XMLFORMAT = None
 The XMLFORMAT parameter controls the generation of the XMLExport and XMLImport. More...
 
 XMLIGNOREINVALIDATTRIBUTE = None
 The XMLIGNOREINVALIDATTRIBUTE parameter allows the programmer to control handling of unexpected. More...
 
 XMLIGNOREINVALIDTAG = None
 The XMLIGNOREINVALIDTAG parameter allows the programmer to control handling of unexpected. More...
 
 XMLIGNORENULL = None
 XMLIGNORENULL allows the programmer to override the default XML handling. More...
 
 XMLINCLUDEINGROUP = None
 XMLINCLUDEINGROUP allows the programmer to control whether a class is included. More...
 
 XMLINHERITANCE = None
 If the XMLINHERITANCE parameter is set to "LEFT", then in the case of multiple. More...
 
 XMLNAME = None
 This parameter provides the default XMLNAME for the class. More...
 
 XMLNIL = None
 The XMLNIL class parameter controls the use of xsi:nil by XMLExport. More...
 
 XMLNILNOOBJECT = None
 The XMLNILNOOBJECT parameter allows creation of an object to be skipped for elements. More...
 
 XMLPREFIX = None
 The XMLPREFIX parameter controls the prefix to be used for the XML namespace that. More...
 
 XMLSEQUENCE = None
 If the XMLSEQUENCE = 1, then the order of the XML elements must match the. More...
 
 XMLSUMMARY = None
 The summary fields to be used when an object is referenced are specified. More...
 
 XMLTYPE = None
 This parameter provides the default XMLTYPE for the class. More...
 
 XMLUNSWIZZLE = None
 If the XMLUNSWIZZLE parameter is set to 1, then single object. More...
 
 XMLUSEEMPTYELEMENT = None
 If the XMLUSEEMPTYELEMENT parameter is set to 1, then the empty element shorthand (<tag>) More...
 

Private Member Functions

_.Library.Status SetTargetObject (_.Library.RegisteredObject pObject)
 Set pObject as the target object for this provider. More...
 

Static Private Member Functions

_.Library.DynamicAbstractObject ArrayToAET (pMetaData, pData)
 Convert the contents of the local array pData to an AET structure. More...
 
_.Library.Status ArrayToJSON (pMetaData, pData, _.Library.String pFormat)
 Write out the contents of the local array pData to the current device using JSON notation. More...
 
_.Library.Status ConvertJSONToObject (_.Library.String pContent, _.Library.String pTargetClass, _.Library.RegisteredObject pObject, _.Library.Boolean pIgnoreUnknownProps)
 Utility method to allow direct use of JSON from a non-ZEN context (such as a CSP page). More...
 
_.Library.DynamicAbstractObject ObjectToAET (_.Library.RegisteredObject pObject, pVisited, _.Library.Integer pLevel, _.Library.String pFormat)
 Convert the contents of object instance pObject to. More...
 
_.Library.Status ObjectToJSON (_.Library.RegisteredObject pObject, pVisited, _.Library.Integer pLevel, _.Library.String pFormat)
 Write out the contents of object instance pObject to. More...
 
_.Library.String WriteJSONFromArray (_.Library.String pVar, _.Library.String pClass, _.Library.String pArrayMethod, _.Library.String pParms, _.Library.Boolean pReturnStatus, _.Library.String pFormat)
 Utility method to allow direct use of JSON from a non-ZEN context (such as a CSP page). More...
 
_.Library.String WriteJSONFromObject (_.Library.String pVar, _.Library.String pClass, _.Library.String pMethod, _.Library.String pParms, _.Library.Boolean pReturnStatus, _.Library.String pFormat)
 Utility method to allow direct use of JSON from a non-ZEN context (such as a CSP page). More...
 
_.Library.Status WriteJSONStreamFromArray (_.Stream.Object pStream, _.Library.String pClass, _.Library.String pArrayMethod, _.Library.String pParms, _.Library.Boolean pRewindStream, _.Library.String pFormat)
 Utility method to allow JSON output to be written to a stream from a general non-ZEN context. More...
 
_.Library.Status WriteJSONStreamFromObject (_.Stream.Object pStream, _.Library.String pObject, _.Library.String pMethod, _.Library.String pParms, _.Library.Boolean pRewindStream, _.Library.String pFormat)
 Utility method to allow JSON output to be written to a stream from a general non-ZEN context. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from Adaptor
_.Library.Status XMLDTD (_.Library.String top, _.Library.String format, _.Library.Boolean input, dtdlist)
 Write the DTD to the current device for this XML enabled class serialized as. More...
 
_.Library.RegisteredObject XMLNew (_.XML.Document document, _.Library.Integer node, _.Library.RegisteredObject containerOref)
 Get an instance of an XML enabled class. More...
 
_.Library.Status XMLSchema (_.Library.String top, _.Library.String format, _.Library.String namespacePrefix, _.Library.Boolean input, _.Library.Boolean refOnly, schema)
 Write an XML Schema fragment to the current device which describes an XML enabled class and dependent classes. More...
 
_.Library.String XMLSchemaNamespace ()
 Get the namespace to which this class belongs for use in schema generation. More...
 
_.Library.Status XMLSchemaType (_.XML.Schema schemaInstance, _.XML.Node node, _.Library.String top, _.Library.Boolean encoded, _.Library.Boolean summary, _.Library.Boolean input, _.Library.Boolean refOnly)
 Add a complexType to the schema that is respresented by an <class>XML.Schema</class> instance. More...
 

Detailed Description

The jsonProvider component provides a way to transport object data between a server and client (and vice versa) using JavaScript Object Notation (commonly abbreviated as JSON), as defined in RFC4627.


JSON format refers to a common JavaScript programming technique where you define a set of one or more objects using object literal syntax:

var obj = { "name": "Bill" };

The jsonProvider works as follows:

  • You place an instance of the (invisible) jsonProvider component on your page.
  • You supply a callback method, <property>OnGetTargetObject</property>, that creates an object or set of objects and returns it. This can be an instance of a specific class or classes or it can use the generic <class>ZEN.proxyObject</class>.
  • The jsonProvider converts the target object to a set of JavaScript objects when the page is rendered (which you can see if you view the source of the page as sent to the client).
  • The jsonProvider has a client-side method, <method>getContentObject</method>(), which returns the client-side version of the target object. This is simply a graph of generic JavaScript Object objects. These objects will have the same properties and values as the target objects. If the target objects refer to other objects or have collections (literal or object-valued) then the JavaScript object will have corresponding object or collection properties.
  • The client can modify these client-side objects or replace them completely using the <method>setContentObject</method>() method.
  • The client can ship its content objects back to the server for processing by calling the <method>submitContent</method>() method. This converts the objects back into server-side objects and invokes the callback method specified by the <property>OnSubmitContent</property> property.
  • The callback defined by <property>OnSubmitContent</property> can modify the objects shipped to it or return a completely different set of objects. This makes it possible to use the jsonProvider as a way to execute different types of server operations.

Using the jsonProvider component as an object transport has advantages and disadvantages when compared with other mechanisms provided by Zen, such as the built-in transport provided for Zen components. The main advantage is that you can transport data without having to create or modify server classes — you can ship most any server-side object using this technique. The disadvantages are:

  • You can ship a set of objects, but the objects must form a graph from a "parent" object down through levels of "children" (this is due to how JSON format data is reconstituted on the client). You cannot have child objects refer to parents, siblings or other objects outside of the graph.
  • This approach uses late binding so it is not as efficient as the code generated approach used by Zen components.
  • Not all object properties are supported: you cannot ship binary streams or values. Only references to "child" objects are transported. Any user-defined Javascript properties whose name starts with "_" (an underscore) are not included in the content shipped back to the server.

The jsonProvider code may also be invoked from a non-Zen context by calling one of the following APIs:

  • <method>WriteJSONFromArray</method>
  • <method>WriteJSONFromObject</method>
  • <method>WriteJSONStreamFromArray</method>
  • <method>WriteJSONStreamFromObject</method>
  • <method>ConvertJSONToObject</method>

Member Function Documentation

◆ ArrayToAET()

_.Library.DynamicAbstractObject ArrayToAET (   pMetaData,
  pData 
)
staticprivate

Convert the contents of the local array pData to an AET structure.

pMetaData is a $List containing the names of the properties of the objects in the order in which they will appear.
pData is an array containing the data. Each node in the array should be a $List containing values for properties. This should match the meta data provided in pMetaData. The array of data can use any subscript value its wants. It is possible to define a hierarchical array. In this case, children nodes are placed within a parent collection called children.

◆ ArrayToJSON()

_.Library.Status ArrayToJSON (   pMetaData,
  pData,
_.Library.String  pFormat 
)
staticprivate

Write out the contents of the local array pData to the current device using JSON notation.

pMetaData is a $List containing the names of the properties of the objects in the order in which they will appear.
pData is an array containing the data. Each node in the array should be a $List containing values for properties. This should match the meta data provided in pMetaData. The array of data can use any subscript value its wants. It is possible to define a hierarchical array. In this case, children nodes are placed within a parent collection called children.
pFormat is a flags string that controls output formatting options.
The following character option codes are supported:
1-9 : indent with this number of spaces (4 is the default with the 'i' format specifier)
b - line break before opening { of objects
i - indent with 4 spaces unless 't' or 1-9
n - newline (lf)
s - use strict JSON output - NOTE: special care should be taken when sending data to a browser, as using this flag may expose you to cross site scripting (XSS) vulnerabilities if the data is sent inside <script> tags. Zen uses this technique extensively, so this flag should NOT be specified for jsonProviders in Zen pages.
t - indent with tab character
u - output pre-converted to UTF-8 instead of in native internal format
w - Windows-style cr/lf newline

◆ ConvertJSONToObject()

_.Library.Status ConvertJSONToObject ( _.Library.String  pContent,
_.Library.String  pTargetClass,
_.Library.RegisteredObject  pObject,
_.Library.Boolean  pIgnoreUnknownProps 
)
staticprivate

Utility method to allow direct use of JSON from a non-ZEN context (such as a CSP page).


pContent is a string or a stream containing JSON notation.
pTargetClass is an optional class type for the resulting object; if not provided, <class>ZEN.proxyObject</class> is used.
pObject is the object created from the JSON. pIgnoreUnknownProps controls whether properties that are not defined in the object structure will be ignored or treated as an error condition. The default behaviour is to stop processing the incoming JSON.

◆ ObjectToAET()

_.Library.DynamicAbstractObject ObjectToAET ( _.Library.RegisteredObject  pObject,
  pVisited,
_.Library.Integer  pLevel,
_.Library.String  pFormat 
)
staticprivate

Convert the contents of object instance pObject to.

an abstract entity tree. pFormat is a flags string to control output options. The following character option codes are supported:
c - output the ObjectScript-specific "_class" and "_id" properties
d - output numeric properties that have value "" as null

◆ ObjectToJSON()

_.Library.Status ObjectToJSON ( _.Library.RegisteredObject  pObject,
  pVisited,
_.Library.Integer  pLevel,
_.Library.String  pFormat 
)
staticprivate

Write out the contents of object instance pObject to.

the current device using JSON notation.

Reimplemented in jsonMDXProvider.

◆ SetTargetObject()

_.Library.Status SetTargetObject ( _.Library.RegisteredObject  pObject)
private

Set pObject as the target object for this provider.


Set <property>targetClass</property> to the target object class.

◆ WriteJSONFromArray()

_.Library.String WriteJSONFromArray ( _.Library.String  pVar,
_.Library.String  pClass,
_.Library.String  pArrayMethod,
_.Library.String  pParms,
_.Library.Boolean  pReturnStatus,
_.Library.String  pFormat 
)
staticprivate

Utility method to allow direct use of JSON from a non-ZEN context (such as a CSP page).


Calls the class method pArrayMethod within the class pClass and converts the resulting array to an array of objects in JSON format using the convention of the <property>OnGetArray</property> callback.
The JSON notation is written out to the current device.
pVar is the optional name of the client-side Javascript variable that refers to the JSON notation.
pParms is an optional array of parameter names and values that is passed to the callback method.
pReturnStatus is a flag to control whether the status code from the method should be returned to the caller. If pReturnStatus is 0, an alert will be raised via Javascript. If pReturnStatus is 1, the status code will be used as the return value from the method and an alert will NOT be raised.
pFormat is provided for signature compatibility with the legacy jsonProvider class, but using it to pretty-print the output stream is not supported by this class.
From a CSP page, you could invoke the method as follows:

#(##class(ZEN.Auxiliary.jsonProvider).WriteJSONFromArray("json",$classname(),"GetArray"))#

◆ WriteJSONFromObject()

_.Library.String WriteJSONFromObject ( _.Library.String  pVar,
_.Library.String  pClass,
_.Library.String  pMethod,
_.Library.String  pParms,
_.Library.Boolean  pReturnStatus,
_.Library.String  pFormat 
)
staticprivate

Utility method to allow direct use of JSON from a non-ZEN context (such as a CSP page).


Calls the class method pMethod within the class pClass and converts the resulting object to JSON format using the convention of the <property>OnGetTargetObject</property> callback.
The JSON notation is written out to the current device.
pVar is the optional name of the client-side Javascript variable that refers to the JSON notation.
pParms is an optional array of parameter names and values that is passed to the callback method.
pReturnStatus is a flag to control whether the status code from the method should be returned to the caller. If pReturnStatus is 0, an alert will be raised via Javascript. If pReturnStatus is 1, the status code will be used as the return value from the method and an alert will NOT be raised.
pFormat is provided for signature compatibility with the legacy jsonProvider class, but using it to pretty-print the output stream is not supported by this class.
From a CSP page, you could invoke the method as follows:

#(##class(ZEN.Auxiliary.jsonProvider).WriteJSONFromObject("json",$classname(),"GetObject"))#

◆ WriteJSONStreamFromArray()

_.Library.Status WriteJSONStreamFromArray ( _.Stream.Object  pStream,
_.Library.String  pClass,
_.Library.String  pArrayMethod,
_.Library.String  pParms,
_.Library.Boolean  pRewindStream,
_.Library.String  pFormat 
)
staticprivate

Utility method to allow JSON output to be written to a stream from a general non-ZEN context.


Calls the class method pArrayMethod within the class pClass and converts the resulting array to an array of objects in JSON format using the convention of the <property>OnGetArray</property> callback.
The JSON notation is written out to the stream supplied in pStream.
pParms is an optional array of parameter names and values that is passed to the callback method.
pRewindStream is a flag to control whether the stream should be rewound after the data is written to it.
pFormat is provided for signature compatibility with the legacy jsonProvider class, but using it to pretty-print the output stream is not supported by this class.

◆ WriteJSONStreamFromObject()

_.Library.Status WriteJSONStreamFromObject ( _.Stream.Object  pStream,
_.Library.String  pObject,
_.Library.String  pMethod,
_.Library.String  pParms,
_.Library.Boolean  pRewindStream,
_.Library.String  pFormat 
)
staticprivate

Utility method to allow JSON output to be written to a stream from a general non-ZEN context.


Calls the class method pMethod within the class pClass and converts the resulting object to JSON format using the convention of the <property>OnGetTargetObject</property> callback. However, if an object is supplied in pClass, then the supplied object will be used as the source object.
The JSON notation is written out to the stream supplied in pStream.
pParms is an optional array of parameter names and values that is passed to the callback method. If pClass is an object, these parameters will be ignored.
pRewindStream is a flag to control whether the stream should be rewound after the data is written to it.
pFormat is provided for signature compatibility with the legacy jsonProvider class, but using it to pretty-print the output stream is not supported by this class.

◆ getData()

getData (   d1,
  d2,
  d3 
)

dataSet API

Return the data contained in the specified location. Location is 0-based.

Reimplemented from abstractController.

◆ getDataAsArrays()

getDataAsArrays ( )

This is a specialized variant of <method>getData</method>() that.

returns the data in this controller as an array of arrays (used by charts).

Reimplemented from abstractController.

◆ getDataSourceCaption()

getDataSourceCaption (   which,
  text 
)

Return a title to display for this data source.

This provides the title for a chart.
which indicates which type of caption: "title", "subtitle",etc. text is the original text for the caption.

◆ getDimSize()

getDimSize (   dim)

Return the number of items in the specified dimension.

(dim is 1,2, or 3).

Reimplemented from abstractController.

◆ getError()

getError ( )

Get the current value of the <property>error</property> property.

This is set when a server-side method encounters an error.

Reimplemented from abstractController.

◆ getLabel()

getLabel (   n,
  dim 
)

Get the label at position n (0-based) in the given.

dimension (1,2, or 3).

Reimplemented from abstractController.

◆ reloadContents()

reloadContents ( )

Reload the contents of the provider with data from the server.


Unlike the <method>submitContent</method>() method, this does not send data to the server.
This is typically used in conjunction with the <property>OnGetArray</property> callback — this method will call the server and the server, in turn, will invoke the <property>OnGetArray</property> callback to create new content to ship back to the client.

◆ reloadContentsAsynch()

reloadContentsAsynch (   notify,
  time 
)

Reload the contents of the json provider asynchronously;.

invoke the function notify when complete. If time is defined, then raise the notify function every time ms until the task is complete.

◆ save()

save ( )

Save data from this dataController back to the DataModel on the server.

Return the id with which the model was saved or '' if it was not saved.

Reimplemented from abstractController.

◆ setContentText()

setContentText (   json)

Set the content for this provider using the string json.

json is expected to contain object data in JSON format.

◆ submitContent()

submitContent (   command,
  targetClass,
  notify,
  time 
)

Send the current target object for this provider to the server.

for processing. This will recreate the object on the server and invoke the <property>OnSubmitContent</property> callback.
This method will return true if successful and false otherwise. If the method fails, an error string is placed in this object's <property>error</property> property (accessible via the <method>getError</method>() method).
command is an optional string that is passed on to the server callback method to allow for different behaviors in the server logic.
targetClass is an optional argument that, if specified, should be the name of the server-class that you wish to have instantiated on the server. This has the same effect as setting the <property>targetClass</property> property. This makes it possible to submit content for different object classes. If the server cannot create an instance of the specified class, it will return an error.
Normally the submit operation is synchronous. If the optional notify parameter is a function, then the operation will be invoked asynchronously and notify will be invoked when the operation is complete. Note that only one asynchronous operation can be handled at a time.
If time is defined, then raise the notify function every time milliseconds until the task is complete.

Member Data Documentation

◆ OnGetArray

OnGetArray

Supply data for the JSON provider as a server-side array.


This callback method is invoked when the page containing this jsonProvider is rendered.
This callback provides an easy way to ship a set of identical objects to the client by filling in a multidimensional array. The callback method is expected to fill in two structures:
pMetaData is a $List containing the names of the properties of the objects in the order in which they will appear.
pData is an array containing the data. Each node in the array should be a $List containing values for properties. This should match the meta data provided in pMetaData. The array of data can use any subscript value its wants. It is possible to define a hierarchical array. In this case, children nodes are placed within a parent collection called children.
If this callback is defined, then the <property>OnGetTargetObject</property> callback will not be invoked. For example:

Method GetArray( ByRef pParameters As String, Output pMetaData, Output pData) As Status { Set pMetaData = $LB("name","rank","serialNo") Set pData(1) = $LB("Smith","Captain","444-33-2222") Set pData(1,1) = $LB("Jones","Corporal","333-22-3333") Quit $$$OK }

This would result in the two objects being shipped to the client (in JSON format):

var content = { "name": "Smith", "rank": "Captain", "serialNo": "444-33-2222", "children": [ { "name": "Jones", "rank": "Corporal", "serialNo": "333-22-3333" } ] };

 

◆ OnGetTargetObject

OnGetTargetObject

Supply data for the JSON provider as a set of server objects.


This callback method is invoked when the page containing this jsonProvider is rendered. It is expected to return (by reference) an instance of the object whose data is to be provided to the client in JSON format.
For example:

Method GetTarget( ByRef pParameters As String, Output pObject As RegisteredObject) As Status { Set pObject = ##class(MyApp.MyClass).New() Set pObject.Name = "Bob" Quit $$$OK }

 

◆ OnRenderJSON

OnRenderJSON

Optional.

If implemented this callback is expected to write out

to the current device the contents of a set of related objects in JSON format.
If present, this overrides the default behavior of this component and the <property>OnGetTargetObject</property> callback is ignored.  

◆ OnSubmitContent

OnSubmitContent

This callback method is invoked when the client submits an object to the.

server by calling the <method>submitContent</method>() method. The callback is passed the submitted object in pSubmitObject after it has been converted from JSON format back into an object instance. It is also passed the command string supplied to the <method>submitContent</method>() method in pCommand.
If the callback method returns an object via the pResponseObject argument, then this object is returned to the client and becomes the new content of the JSON provider.
For example:

Method SubmitHandler( pCommand As String, pProvider As ZEN.Auxiliary.jsonProvider, pSubmitObject As RegisteredObject, Output pResponseObject As RegisteredObject) As Status { Set tSC = $$$OK If ($IsObject(pObject)) { Set tSC = pObject.Save() } Quit tSC }

 

◆ documentId

documentId

Optional.

If provided (and no other callbacks are defined), then

this is the id of a document interface (subclass of <class>ZEN.DataModel.AbstractDocument</class>) that is used to supply data to the provider.
A document id takes the form "docName/docInstance", where docName is the logical name of a data document and docInstance is a instance id.  

◆ error

error

Run-time value.

Set to indicate an error within this component.

This is primarily used by controls. It is defined here for flexibility.  

◆ parameters

parameters

User-defined set of parameters.

These values are passed on

to the user callback function that provides the contents of this view. Typically this is used to hold search parameters.  

◆ propertyList

propertyList

Optional.

If supplied this is an comma-delimited list of property names. These names are used to define the default ordering of properties supplied by this provider. If a property name is in the list but not in the content data, it is used but will have a value of ''. Properties in the content object but not in this list are listed at the end.  

◆ seriesNameProperty

seriesNameProperty

Optional.

When this provider is used as a data controller, this is the name of the property in the JSON data that provides the series names to view connected to the provider. The default is "caption".  

◆ targetClass

targetClass

Class name of the target object expected to be served by this component.

Setting the target object will also set this as a side effect.