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()

Constructs a new 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

setTrackEntity(entity)

Sets the current entity.

Parameters:
Name Type Description
entity string

new current entity

Example
context.setTrackEntity("MyFirstProject.Pizza");

setTrackId(guid)

Sets the current GUID of the context and resets the current object.

It does not affect the current entity.

Parameters:
Name Type Description
guid GUID

new current GUID

Example
context.setTrackId(obj.getGuid());

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.setTrackId(obj);