Skip to main content
Skip table of contents

this Context

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. As already mentioned on JavaScript Specifics > Limitations, xUML class operations cannot be accessed from within a JavaScript.

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

this.<property name>

Use this notation to access to a property of the related class.

this.location.storageUnit.shelf

You only have access to the properties of the Product class (id, name, location). You cannot call the related operations updateStock() and updateStorageSystem() from within JavaScript.

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.