mx.processor
The mendix.sys.Processor
subsystem provides an API to retrieve and manipulate MxObjects.
Properties
-
Methods
startup(callback)
This method is called to startup the subsystem.
Parameters
Name | Type | Description |
---|---|---|
callback | Function | The function to be called when startup is finished. |
Returns
-
shutdown()
This method is called to shutdown the subsystem.
Parameters
-
Returns
-
isLoaded()
This method is called to check whether the subsystem has been started.
Parameters
-
Returns
Type | Description |
---|---|
Boolean | true if the subsystem has been started. |
makeChange(mxobj, attr, value)
This method is called to make a change to a MxObject, and distribute it to all listeners.
Parameters
Name | Type | Description |
---|---|---|
mxobj | MxObject | The MxObject to make a change to. |
attr | String | The attribute to change. |
value | Variable | The value to assign to the attribute. |
Returns
-
objectUpdateNotification(mxobj)
This method is called to distribute an object update to all guid and entity listeners.
Parameters
Name | Type | Description |
---|---|---|
mxobj | MxObject | The MxObject to distribute. |
Returns
-
objectPing(mxobj)
This method is called to distribute an object update to all guid listeners.
Parameters
Name | Type | Description |
---|---|---|
mxobj | MxObject | The MxObject to distribute. |
Returns
-
createXPathString(args)
This method is called to create a XPath query, based on an entity and a MxContext.
Parameters
Name | Type | Description |
---|---|---|
args.entity | String | The entity to create an XPath query for. |
args.context | MxContext | The context on which the query constrains. |
args.callback | String | The function to handle the result. |
args.error | String | The function to handle errors. |
Returns
-
get(args, scope)
This method is called to retrieve MxObjects from the Runtime.
Parameters
Only one of the guid / guids / xpath / microflow parameters should be set.
Name | Type | Description |
---|---|---|
args.guid | Number | The GUID of the object to retrieve. |
args.guids | Array | The GUIDS of the objects to retrieve. |
args.xpath | String | The XPath query to retrieve. |
args.microflow | Boolean | A microflow to fetch objects from. |
args.callback | Function | Function to handle the result. |
args.error | Function | Function to handle errors. |
args.noCache | Boolean | Whether the client cache should be used. |
args.count | Boolean | Whether a count of the entire set should be returned. |
args.filter.id | String | Schema-id. |
args.filter.attributes | Array | If given, only given attributes will be fetched. |
args.filter.offset | Number | Index from where to start in the set. |
args.filter.sort | Array | Attribute and sort order pairs on which to sort the objects on. |
args.filter.amount | Number | Maximum number of objects to fetch. |
args.filter.distinct | Boolean | Distinct objects on an attribute. |
args.filter.references | Object | Key-value pairs of reference name and options. |
scope | Object | Scope in which the error and callback handler are invoked. |
Returns
If one GUID is requested:
Type | Description |
---|---|
MxObject | The requested MxObject |
Else:
Type | Description |
---|---|
Array | Array with requested objects |
Examples
mx.processor.get({ guids : [123456, 456789], callback : function(objs) { console.log("Received " + objs.length + " MxObjects"); } });
mx.processor.get({ guid : 123456, callback : function(obj) { console.log("Received MxObject with GUID " + obj.getGUID()); } });
mx.processor.get({ xpath : "//System.User", callback : function(objs) { console.log("Received " + objs.length + " MxObjects"); } });
mx.processor.get({ xpath : "//System.User", filter : { sort : [["Name", "asc"]], offset : 0, amount : 10 }, callback : function(objs) { console.log("Received " + objs.length + " MxObjects"); } });
getBacktrackConstraints(metaobj, context, callback)
This method is called to create XPath constraints, based on an MxMetaObject and a MxContext.
Parameters
Name | Type | Description |
---|---|---|
metaobj | MxMetaObject | The MxMetaObject of the entity. |
context | MxContext | The context on which the constraints constrain. |
callback | String | The function to handle the result. |
Returns
-
create(args, scope)
This method is called to create a MxObject.
Parameters
Name | Type | Description |
---|---|---|
args.entity | String | Entity to create an instance of. |
args.callback | Function | Function to handle the result. |
args.error | Function | Function to handle errors. |
scope | Object | Scope in which the error and callback handler are invoked. |
Returns
-
save(args, scope)
This method is called to save a MxObject.
Parameters
Name | Type | Description |
---|---|---|
args.mxobj | MxObject | MxObject to save changes for. |
args.callback | Function | Function to handle the result. |
args.error | Function | Function to handle errors. |
scope | Object | Scope in which the error and callback handler are invoked. |
Examples
mx.processor.save({
mxobj : obj,
callback : function() {
console.log("Object saved");
}
});
Returns
-
commit(args, scope)
This method is called to commit a MxObject.
Parameters
Name | Type | Description |
---|---|---|
args.mxobj | MxObject | MxObject to save changes for. |
args.callback | Function | Function to handle the result. |
args.error | Function | Function to handle errors. |
args.onValidation | Function | Function to handle validation feedback. |
args.standalone | Boolean | Whether other changes may be sent along. |
scope | Object | Scope in which the error and callback handler are invoked. |
Returns
-
Examples
mx.processor.commit({
mxobj : obj,
callback : function() {
console.log("Object committed");
},
error : function(err) {
console.log("Error occurred attempting to commit " + err);
}
});
rollback(args, scope)
This method is called to rollback a MxObject.
Parameters
Name | Type | Description |
---|---|---|
args.mxobj | MxObject | MxObject to save changes for. |
args.callback | Function | Function to handle the result. |
args.error | Function | Function to handle errors. |
scope | Object | Scope in which the error and callback handler are invoked. |
Returns
-
remove(args, scope)
This method is called to remove MxObjects. Only one of the guid / guids parameters should be set.
Parameters
Name | Type | Description |
---|---|---|
args.guid | Number | GUID of MxObject to remove. |
args.guids | Array | GUIDS of MxObjects to remove. |
args.callback | Function | Function to handle the result. |
args.error | Function | Function to handle errors. |
scope | Object | Scope in which the error and callback handler are invoked. |
Returns
-
Examples
mx.processor.remove({ guid : 123456, callback : function() { console.log("Object removed"); }, error : function(err) { console.log("Error occurred attempting to remove object " + err); } });
mx.processor.remove({ guids : [123456, 45678], callback : function() { console.log("Objects removed"); }, error : function(err) { console.log("Error occurred attempting to remove objects " + err); } });
subscribe(args)
This method is called to register a callback to be invoked on changes in a specific MxObject, an attribute of a specific MxObject or any changes to MxObjects of a specific entity. Widgets inherit a method from Widget, this.connect() which automatically sets up an unsubscription function to be run on Widget teardown.
Parameters
Name | Type | Description |
---|---|---|
args.guid | Number | The GUID to subscribe to |
args.entity | String | The entity to subscribe to |
args.attr | String | The attribute to subscribe to |
args.callback | Function | The callback to invoke when an update is available |
Returns
Type | Description |
---|---|
Object | Handler which can be passed to unsubscribe to remove the subscription |
Examples
// // Subscribe to all changes in an MxObject //
mx.processor.subscribe({ guid : 123213, callback : cb // # GUID });
// // Subscribe to changes in a specific attribute of an MxObject //
mx.processor.subscribe({ guid : 123213, attr : 'Name', callback : cb // # GUID });
// // Subscribe to validations of an MxObject //
mx.processor.subscribe({ guid : 123213, val : true, callback : cb // # GUID });
// // Subscribe to changes in a class //
mx.processor.subscribe({ class : 'System.User', callback : cb });
unsubscribe(args)
This method is called to unregister a callback to be invoked on changes in a specific MxObject, an attribute of a specific MxObject or any changes to MxObjects of a specific entity. Unregistering callbacks when they are no longer needed is important to prevent memory leaks. Widgets inherit a method from Widget, this.connect() which automatically sets up an unsubscription function to be run on Widget teardown.
Parameters
Name | Type | Description |
---|---|---|
args | Object | Handler which should be the return value of a subscribe call |
Returns
-