Prev Next

Using Scriptlets in MDG Technologies

Scriptlets can be incorporated into the definition of a element stereotype, as part of a Profile in an MDG Technology.  In this way, Scriptlets can be used to perform on-the-fly changes to an element's properties and presentation.

To add a Scriptlet to an element stereotype, within the element used to define the stereotype, create an attribute named '_scriptlet' and place the script code into the 'Initial Value' field of that attribute's properties.  The JavaScript language is used to write the Scriptlet code.

For more detail see _scriptlet  in the Special Attributes Help topic.

Example Use of a Scriptlet in a Stereotype

In this example, the element that defines the stereotype 'Person', defines (among other things) three attributes, 'Height', 'Weight' and 'BMI'. It also defines the special attribute '_scriptlet', that assigns a value to 'BMI', that is calculated as 'Weight' divided by the square of 'Height'.

Here is an example of an element created using the 'Person' stereotype, that includes the BMI Scriptlet.

Note that the attributes of the stereotype, become Tagged Values in elements created with that stereotype.

Learn More