Class: mendix/lib/MxContext

mendix/lib/MxContext

An object that is passed to context aware widgets. An instance contains the GUID and entity relevant to the widget instance.

It also keeps track of which object is in its scope for a certain entity.

This class should never be instantiated manually.

Constructor

new mendix/lib/MxContext()

Methods

getTrackEntity() → {string}

Returns the current entity.

Returns:

current entity

Type
string
Example
context.getTrackEntity();   // "MyFirstProject.Pizza"

getTrackId() → {string}

Returns the current GUID.

Returns:

the current GUID

Type
string
Example
context.getTrackId();   // "12345"

getTrackObject() → {mendix/lib/MxObject}

Returns the current object.

Returns:

the current object

Type
mendix/lib/MxObject
Example
var obj = context.getTrackObject();
obj.getGuid();  // "12345"

hasTrackEntity() → {boolean}

Checks whether this context has a current entity.

Returns:

true if there is a current entity, false otherwise

Type
boolean
Example
context.hasTrackEntity();   // true

hasTrackId() → {boolean}

Checks whether this context has a current GUID.

Returns:

true if there is a current GUID, false otherwise.

Type
boolean
Example
context.hasTrackId();   // true

hasTrackObject() → {mendix/lib/MxObject}

Checks whether this context has a current object.

Returns:

true if there is a current object, false otherwise

Type
mendix/lib/MxObject
Example
context.hasTrackObject();   // true

setContext(entity, guid)

Sets current entity and GUID and maps GUID to entity in scope.

It clears the current object.

Parameters:
Name Type Description
entity string

entity to set

guid GUID

GUID to set

Example
context.setContext("MyFirstModule.Entity", "12345");

setTrackObject(obj)

Sets the current object and sets it in scope for its entity.

Parameters:
Name Type Description
obj mendix/lib/MxObject

new current object

Example
context.setTrackObject(obj);