You can use ListActions in a ViewModel expression to retrieve the actions available for a specified nesting and use their metadata when you customize how actions appear in the user interface.
Use ListActions
ListActions is an OCL operator on selfVM. It returns the available actions for a nesting as a collection of ActionInstance values.
Use the nesting reference rather than a hard-coded nesting name when possible. Passing selfVM.Nesting gives better error checking if the nesting name changes.
selfVM.ListActions(selfVM.Nesting)
For example, if the current ViewModel context is the nesting whose actions you want to display, this expression gives you the collection of action instances that are available in that context.
Arguments and return value
| Item | Type | Description |
|---|---|---|
nameofNesting
|
String | The name of the ViewModel nesting whose available actions you want to list. Use selfVM.Nesting instead of a literal name when it represents the intended nesting.
|
| Return value | Collection(ActionInstance)
|
A collection containing the action instances available for that nesting. |
Read action metadata
Each returned ActionInstance describes an action and the information needed to present it. For example, you can use Enabled to identify actions that can currently run, Hint for hover information, and Group to organize actions in menus.
| Attribute | Type | Meaning |
|---|---|---|
ActionName
|
String | The name of the action. |
Enabled
|
Boolean | true when the action is enabled.
|
Group
|
String | The name of the action's menu group. |
Hint
|
String | Extra information shown when the pointer is over the action UI widget. A hint is available for both enabled and disabled actions. |
IsNavigating
|
Boolean | true when the action navigates to another ViewModel.
|
NestingName
|
String | The name of the ViewModel nesting for the action. |
Presentation
|
String | The string representation of the ViewModel. |
When to use it
Use ListActions when you build or customize an action display and need to discover the actions available in a particular nesting. It lets the UI use the action definition's name, group, hint, enabled state, and navigation behavior rather than duplicating that information.
For example, an action menu can obtain the available action instances for a nesting, place actions with the same Group together, display Hint as hover text, and retain disabled actions so that their hints remain available.
ListActions lists available actions; it does not execute them. Before running a known action from OCL, use CanExecuteAction to check whether it can run, then use the appropriate action-execution mechanism. See Documentation:Actions for action types and behavior.
