mendix.lib.MxMetaObject
mendix.lib.MxMetaObject
is an Object that provides access to meta data of an Entity in the current session associated with an application specific Domain Model.
mendix.lib.MxMetaObject
should never be instantiated manually.
Methods
getAttributes()
This method will return an Array containing the names of all the attributes in this MxMetaObject.
Returns
Type |
Description |
Array |
The names of the attributes |
Example
var attrs = mxmetaobject.getAttributes(); // [ "Name", "Age" ];
getAttributesWithoutReferences()
Retrieve the names of all non-reference attributes.
Returns
Type |
Description |
Array |
The names of the attributes |
getReferenceAttributes()
Retrieve the names of all reference attributes.
Returns
Type |
Description |
Array |
The names of the attributes |
Example
var refs = mxmetaobject.getReferenceAttributes(); // [ "Mod.Person_Parent",
// "Mod.Person_Company" ]
getEntity()
This method will return a String with this object’s Entity name.
Returns
Type |
Description |
String |
Name of the entity |
Example
mxmetaobject.getEntity(); // "System.User"
getEnumCaption(attr, name)
Return the caption of the enumeration value with name name
in attribute attr
.
Parameters
Name |
Type |
Description |
attr |
String |
Name of the attribute |
name |
String |
Name of the enumeration value |
Returns
Type |
Description |
String |
Caption of enumeration value with name name |
Example
mxmetaobject.getEnumCaption("Color", "red"); // "Rouge"
getEnumKVPairs(attr)
Return a map from keys to captions from Enum attribute attr
.
Parameters
Name |
Type |
Description |
attr |
String |
The enumeration attribute to get the pairs for. |
Returns
Type |
Description |
Object |
Mapping from key to caption. |
Example
mxmetaobject.getEnumKVPairs("Color"); // { red : "Red",
// green : "Green",
// blue : "Blue" }
getEnumMap(attr)
Return an Array of enumeration values for Enum attribute attr
, in the correct order.
Parameters
Name |
Type |
Description |
attr |
String |
The enumeration attribute to get the enumeration values for. |
Returns
Type |
Description |
Array |
The ordered enumeration values of attr . Each element is an Object with properties key and caption . |
Example
mxmetaobject.getEnumMap("Color"); // [ { key : "red", caption : "Red" },
// { key : "green", caption : "Green" },
// { key : "blue", caption : "Blue" } ]
getOptions(attr)
Return the names of the possible enumeration values for attribute attr
.
Parameters
Name |
Type |
Description |
attr |
String |
The enumeration attribute to get the keys for. |
Returns
Type |
Description |
Array |
The names of the possible enumeration values of the attribute |
Example
mxmetaobject.getOptions("Color"); // [ "red", "green", "blue" ]
getSelectorEntity(attr)
This method is used to get the Entity of a reference attribute.
Parameters
Name |
Type |
Description |
attr |
String |
The reference attribute whose Entity to return. |
Returns
Type |
Description |
String |
The Entity name |
Example
mxobj.getSelectorEntity('Order_OrderLine'); // "CRM.OrderLine"
getSubEntities()
This method will return an Array with the names of the Entities that inherit from this Entity (if any).
Returns
Type |
Description |
Array |
The names of the inheriting entities |
Example
mxmetaobject.getSubEntities(); // [ "MyModule.EntityA", "MyModule.EntityB" ]
getSuperEntities()
This method will return an Array with the inheritance chain of this Entity (if any).
Returns
Type |
Description |
Array |
The names of the entities in the inheritance chain |
Example
mxmetaobject.getSuperEntities(); // [ "MyModule.EntityC",
// "MyModule.EntityD",
// "System.User" ]
has(attr)
This method is called to determine if this object has the requested attribute and returns true
if it does and false
if it does not.
Parameters
Name |
Type |
Description |
attr |
String |
The name of attribute to check for. |
Returns
Type |
Description |
Boolean |
true if the object has the requested attribute, false otherwise. |
Example
if (mxmetaobject.has("Name")) {
alert("This mxmetaobject does have the attribute 'Name'.");
} else {
alert("This mxmetaobject does not have the attribute 'Name'.");
}
hasSubEntities()
This method is called to determine if other entities inherit from this entity type and returns true
if it does and false
if it doesn’t.
Returns
Type |
Description |
Boolean |
true if the object has inheriting entities, false otherwise. |
Example
if (mxmetaobject.hasSubEntities()) {
alert("Other Entities inherit from this Entity");
} else {
alert("Other Entities do not inherit from this Entity");
}
hasSuperEntities()
This method is called to determine if the entity type of this object inherits from other entities and returns true
if it does and false
if it doesn’t.
Returns
Type |
Description |
Boolean |
true if the object inherites from any entities, false otherwise. |
Example
if (mxmetaobject.hasSuperEntities()) {
alert("This object inherits from another Entity");
} else {
alert("This object does not inherit from another Entity");
}
inheritsFrom(classname)
This method is called to determine if the entity type of this object inherits from classname
and returns true
if it does and false
if it doesn’t.
Parameters
Name |
Type |
Description |
classname |
String |
The name of the entity to check inheritance for. |
Returns
Type |
Description |
Boolean |
true if the object inherits from classname , false otherwise. |
Example
if (mxmetaobject.inheritsFrom("System.User")) {
alert("This object inherits from System.User");
} else {
alert("This object does not inherit from System.User");
}
isA(classname)
This method is called to determine if this object is an instance of, or inherits from classname
and returns true
if it does and false
if it doesn’t.
Parameters
Name |
Type |
Description |
classname |
String |
The name of the entity to check the object for being an instance of. |
Returns
Type |
Description |
Boolean |
true if the object is an instance of classname , false otherwise. |
Example
if (mxmetaobject.isA("System.User")) {
alert("This object is a System.User");
} else {
alert("This object is not a System.User");
}
isBoolean(attr)
This method is a convenience method and is called to determine if attribute attr
of this object is of type Boolean and returns true
if it does and false
if it doesn’t.
Parameters
Name |
Type |
Description |
attr |
String |
The name of attribute to check. |
Returns
Type |
Description |
Boolean |
true if the attribute is of Boolean type, false otherwise |
Example
if (mxmetaobject.isBoolean("Checked")) {
alert("Attribute 'Checked' is a Boolean");
} else {
alert("Attribute 'Checked' is not a Boolean");
}
isCurrency(attr)
This method is a convenience method and is called to determine if attribute attr
of this object is of type Currency and returns true
if it does and false
if it doesn’t.
Parameters
Name |
Type |
Description |
attr |
String |
The name of attribute to check. |
Returns
Type |
Description |
Boolean |
true if the attribute is of Currency type, false otherwise |
Example
if (mxmetaobject.isCurrency("Amount")) {
alert("Attribute 'Amount' is a Currency");
} else {
alert("Attribute 'Amount' is not a Currency");
}
isDate(attr)
This method is a convenience method and is called to determine if attribute attr
of this object is of type Date and returns true
if it does and false
if it doesn’t.
Parameters
Name |
Type |
Description |
attr |
String |
The name of attribute to check. |
Returns
Type |
Description |
Boolean |
true if the attribute is of Date type, false otherwise |
Example
if (mxmetaobject.isDate("DoB")) {
alert("Attribute 'DoB' is a Date");
} else {
alert("Attribute 'DoB' is not a Date");
}
isEnum(attr)
This method is a convenience method and is called to determine if attribute attr
of this object is of type Enumeration and returns true
if it does and false
if it doesn’t.
Parameters
Name |
Type |
Description |
attr |
String |
The name of attribute to check. |
Returns
Type |
Description |
Boolean |
true if the attribute is of Enumeration type, false otherwise |
Example
if (mxmetaobject.isEnum("Colors")) {
alert("Attribute 'Colors' is an Enumeration");
} else {
alert("Attribute 'Colors' is not an Enumeration");
}
isLocalizedDate(attr)
This method is a convenience method and is called to determine if attribute attr
of this object is of type Localized Date and returns true
if it does and false
if it doesn’t.
Parameters
Name |
Type |
Description |
attr |
String |
The name of attribute to check. |
Returns
Type |
Description |
Boolean |
true if the attribute is of Localized Date type, false otherwise |
Example
if (mxmetaobject.isLocalizedDate("DoB")) {
alert("Attribute 'DoB' is a Localized Date");
} else {
alert("Attribute 'DoB' is not a Localized Date");
}
isNumber(attr)
This method is a convenience method and is called to determine if attribute attr
of this object is of type Number and returns true
if it does and false
if it doesn’t.
Parameters
Name |
Type |
Description |
attr |
String |
The name of attribute to check. |
Returns
Type |
Description |
Boolean |
true if the attribute is of Number type, false otherwise |
Example
if (mxmetaobject.isNumber("Count")) {
alert("Attribute 'Count' is a Number");
} else {
alert("Attribute 'Count' is not a Number");
}
isPassword(attr)
This method is a convenience method and is called to determine if attribute attr
of this object is of type Password and returns true
if it does and false
if it doesn’t.
Parameters
Name |
Type |
Description |
attr |
String |
The name of attribute to check. |
Returns
Type |
Description |
Boolean |
true if the attribute is of Password type, false otherwise |
Example
if (mxmetaobject.isPassword("Password")) {
alert("Attribute 'Password' is a Password");
} else {
alert("Attribute 'Password' is not a Password");
}
isObjectReference(attr)
Check whether an attribute is a reference.
Parameters
Name |
Type |
Description |
attr |
String |
The name of attribute to check. |
Returns
Type |
Description |
Boolean |
true if the attribute is a reference, false otherwise |
Example
if (mxmetaobject.isObjectReference("Mother")) {
alert("Attribute Parent is a reference");
} else {
alert("Attribute Parent is not a reference");
}
isObjectReferenceSet(attr)
Check whether an attribute is a reference set.
Parameters
Name |
Type |
Description |
attr |
String |
The name of attribute to check. |
Returns
Type |
Description |
Boolean |
true if the attribute is a reference set, false otherwise |
Example
if (mxmetaobject.isObjectReferenceSet("Children")) {
alert("Attribute Children is a reference set");
} else {
alert("Attribute Children is not a reference set");
}
isReference(attr)
Check whether an attribute is a reference or reference set.
Parameters
Name |
Type |
Description |
attr |
String |
The name of attribute to check. |
Returns
Type |
Description |
Boolean |
true if the attribute is a reference or reference set, false otherwise |
Example
if (mxmetaobject.isReference("Children")) {
alert("Attribute Children is a reference set");
} else {
alert("Attribute Children is not a reference set");
}