You use a nesting to represent a ViewModel section inside another ViewModel section, for example an Order ViewModel with an OrderLines list beneath it.
What a nesting is
In MDriven Designer, a nesting is a ViewModel element contained within the top-level ViewModel. Nestings define the structure of the data and UI that the ViewModel presents.
The top-level ViewModel is shown in green. Its nestings are shown in blue beneath it. A nesting can itself contain further nestings, which lets you model parent-and-child structures.
For example, an Order screen can have this structure:
- Order â the top-level ViewModel
OrderLines â a nesting that presents the lines belonging to the current order * Product â a nesting below an order line when the UI needs product information
This structure is about the ViewModel presentation and navigation context. It is not a generic programming-language concept such as a nested class or function.
Find nestings in MDriven Designer
- Open the ViewModel in MDriven Designer.
- Locate the top-level ViewModel, shown in green.
- Look beneath it for the blue elements. Each blue element is a nesting.
- Use the nesting name when you refer to that ViewModel section from OCL or when you configure behavior that applies to a particular nesting.
For settings that control the ViewModel layout and display, including the depiction of nestings, see Documentation:ViewModel settings.
Use nestings from OCL
A nesting has a name. You can use that name when an OCL operation needs to address a particular ViewModel section.
The selfVM value is the current ViewModel context. selfVM.Nestings returns a tuple containing all nestings in that ViewModel, including the top-level ViewModel. See Documentation:OCLOperators Nestings for the operator definition.
Prefer a nesting reference over a literal name
Some operations take a nesting name as a string. Where available, use the member exposed through selfVM.Nestings instead of repeating the name as a string. This makes a rename detectable: if the nesting is renamed, the expression breaks with a clear error instead of continuing to use an outdated string.
For example, if the ViewModel has a nesting named OrderLines, the following identifies that nesting through selfVM.Nestings:
selfVM.Nestings.OrderLinesThe exact use depends on the operator. For example, ListActions returns the actions available for a nesting, and its documentation describes using selfVM.Nestings to supply the nesting name safely.
Nestings and actions
Actions belong to a ViewModel nesting. This matters when you build a custom action presentation or need to decide whether an action is currently available.
| Need | Use | Example purpose |
|---|---|---|
| Get the actions available for a nesting | selfVM.ListActions | Show the actions for OrderLines in a custom list.
|
| Check whether an action can run | selfVM.CanExecuteAction | Check whether an Approve action can run in an order-list nesting before executing it.
|
ListActions returns action instances, including each action's name, enabled state, group, hint, navigation status, nesting name, and presentation. See Documentation:OCLOperators ListActions for the OCL operator details.
Design example: Order and order lines
Consider a ViewModel that edits one order and displays its lines.
| ViewModel element | Role | Example content |
|---|---|---|
Order
|
Top-level ViewModel | Order number, customer, and order date. |
OrderLines
|
Nesting below Order
|
A collection of line items for the current order. |
Product
|
Nested information below an order line | Product label or other product data needed by the line UI. |
In this example, OrderLines is the name to use when an OCL operation must target the list of lines. If you later rename OrderLines, review expressions that address it and prefer the selfVM.Nestings reference pattern where the relevant operator supports it.
Nested data and UI behavior
A nesting can be displayed as a list, grid, or other UI structure according to its ViewModel configuration. Keep the nesting hierarchy aligned with the data the user works with: put the order lines under the current order, rather than presenting unrelated line data at the same level.
For large or hierarchical data, choose the loading and tree approach that fits the expected data volume. See Documentation:Cursored or Full Tree. For client-side sorting behavior on a nesting, see Documentation:Nesting.ClientSortable.
When working with nested data in Tajson, review generated ReadOnly values carefully. Attributes added to multi-nestings are set to true for ReadOnly; in Tajson, that means read-only also during import.
