You can use selfVM.Nestings in OCL evaluated in a ViewModel context to get the top-level ViewModel and every nesting contained within it.
What it returns
selfVM.Nestings returns a tuple containing all nestings in the current ViewModel hierarchy. The result includes:
- The top-level ViewModel.
- Each nesting placed below that top-level ViewModel.
A nesting is an element arranged within another element. In MDriven Designer, nestings are shown in blue below the top-level ViewModel, which is shown in green. For the structure and purpose of nestings, see Documentation:Nestings.
Syntax
selfVM.NestingsUse this expression where selfVM refers to the current ViewModel.
Example
Assume that a ViewModel named Order has two nestings: Customer and OrderRows.
Order
Customer
OrderRows
Evaluating the following expression in the Order ViewModel context returns a tuple containing Order, Customer, and OrderRows:
selfVM.NestingsThe top-level Order ViewModel is part of the result even though it is not shown as a blue nesting in the ViewModel structure.
When to use it
Use selfVM.Nestings when your OCL needs to work with the complete ViewModel hierarchy rather than one known nesting. For example, use it when an expression needs to inspect or process the current ViewModel together with all of its nested ViewModels.
