To use client-side web memory, 2 conditions must be met:
the webappos.js script has to be included;
webappos.init_web_memory has to be called (this is usually done inside webappos.<request_scopes>("webappos_scopes", "project_id"))
After that, the JavaScript webmem object becomes available. Web memory is accessed through this object.
webmem[r] is a repository element ( |
| ) with the given reference represented as a JavaScript object |
For each repository element (an object, an association end, an attribute, or a class) a client-side JavaScript object is created. If the element has a reference r in the repository, it can be accessed by index r in webmem as webmem[r].
For each class from the model repository of the given webAppOS project, a webmem.ClassName constructor is created. The constructor creates a new repository object of the given class, registers it at the client side, and synchronizes it with the server.
Each class (webmem.ClassName) has the following properties:
Each object (webmem[r]) has the following properties:
There are also internal functions used when synced repository actions are received from the server. These actions correspond to Repository Access API (RAAPI), (see http://webappos.org/dev/raapi).
webmem.createClass(className, r)
webmem.createAttributeSetterGetter(obj, name, rAttr)
webmem.deleteAttributeSetterGetter(obj, name)
webmem.createAttribute(rClass, name, rType, r)
webmem.setAttributeValue(rObj, rAttr, val)
webmem.createAssociationSetterGetter(obj, roleName, rAssoc)
webmem.deleteAssociationSetterGetter(obj, roleName)
webmem.createAssociation(rSourceClass, rTargetClass, sourceRoleName, targetRoleName, isComposition, r1, r2)
webmem.createObject(rClass, r)
...
In addition, there is also the webmem.checkReference function used to register and create new client-side references.
var obj = new webmem.ClassName();
obj.setAttributeName(5);
obj.getAttributeName();
obj.linkRoleName(obj2);
obj.unlinkRoleName(obj2);
var map = webmem.<ClassName>.getAllObjects();
...
The "tda.model" and "webmem" variable names point to the same JS object that can be used to access web memory.
We recommend to use webmem, since tda.model is kept only for compatibility with some legacy code.