Class operations can be static or non-static (see Adding Operation Calls). If an operation is non-static, it can only be executed on a given instance of the related class: You need to provide an object of this class to the target pin of the operation.
In JavaScript, the contents of the target object are available within that operation via the this context. Contents in this case means properties.
For static operations, the keyword this is undefined.
Example
Assume you have the following Product class with
-
the properties
-
id
-
name
-
location
-
-
a non-static updateStock operation that updates a given quantity of the current product to the stock
-
and a static updateStorageSystem operation that updates the storage system with a given quantity
The this context provides the object content via the keyword this to the operation updateStock().
|
Target |
Syntax |
Description |
Customer Example |
|---|---|---|---|
|
Property |
|
Use this notation to access to a property of the related class. |
this.location.storageUnit.shelf |
Related Content
Related Pages:
-
JavaScript Specifics
A comprehensive overview on the general specifics, limitations and exception handling regarding JavaScript operations in xUML services. -
Working with the JavaScript Editor
This page describes the basics of the integrated JavaScript editor.