🚀 Welcome to MDriven Learn –  MDriven is now on Discord!  Don’t miss the latest Release Notes.
Bootcamp:Chapter 5
This page was created by Stephanie on 2023-04-24. Last edited by Wikiadmin on 2026-07-29.

You can create, place, and test actions that open views or act on selected objects in MDriven Designer; this chapter is for Bootcamp learners who completed Training:Bootcamp:Chapter 4.

This chapter uses the PersonSeeker ViewModel created earlier. You will learn how actions determine what users see in the global menu, in a type-specific context, and inside one ViewModel.

Before you begin

  • Complete Training:Bootcamp:Chapter 4 and open the model that contains the PersonSeeker ViewModel.
  • Save frequently with Ctrl+S.
  • Test each completed change in the running web application. In MDriven Designer, save the model before checking the browser.
  • If you lose your place, reopen the relevant ViewModel in the ViewModel Editor and expand its yellow Actions node.

Understand the three action types

An action defines something a user can invoke. The action editor is similar for all action types, but the action's scope determines where it is available.

Action type Scope Where the user sees it Example in this chapter
GlobalAction The application The top-level global menu, optionally in a menu group PersonSeeker opens the PersonSeeker ViewModel
Class action Every object of one class Where the ViewModel has matching type information ShowPerson is available for a Person
ViewModelAction (also called a ContextAction) One ViewModel and its selected level The action area or a control in that ViewModel DeleteThis deletes the selected Person

A ViewModel is the definition of a screen and its data context. An action can bring up a ViewModel, execute behavior in the current context, or be invoked by a button placed in a ViewModel.

Work with GlobalActions

A GlobalAction belongs to the application rather than to a model class. It appears in the global menu unless its menu-group settings place it below a menu item.

Open and rename the PersonSeeker action

  1. In the ViewModel Editor, open PersonSeeker.
  2. Expand the yellow Actions node.
  3. Select the blue /PersonSeeker link to open its action definition.
  4. Change ActionName from PersonSeeker to PersonSeekerIAmInControl.
  5. Observe the generated menu preview above ActionName. It updates when the action name changes.

The list on the left of the action editor contains the GlobalActions currently defined in the model. Select AutoFormCarSeeker to inspect another GlobalAction, then select your renamed PersonSeeker action again.

You can also open the same GlobalAction editor from the model diagram by selecting the cog-wheels tool button.

Control top-level menu placement

The MenuGroup property determines where a GlobalAction appears in the rendered global menu.

  1. Select AutoFormCarSeeker in the GlobalAction list.
  2. Confirm that its MenuGroup is AutoForms. It does not appear as a top-level action in the rendered main menu.
  3. Clear the MenuGroup value.
  4. Confirm that the action now appears beside the PersonSeeker action in the top-level menu.
  5. Restore AutoForms, either with Ctrl+Z or by entering the value again.

A GlobalAction appears in only one menu location. Assigning a menu group removes it from the top level and places it under that group.

Create a nested menu group

A menu-group name can contain levels separated by /.

  1. Select PersonSeekerIAmInControl.
  2. Select the three-dot button (...) beside MenuGroup to open EditMenuGroup.
  3. Select Add menu group.
  4. Enter IControlTheMenuGrouping/AtAllLevels, then close the dialog.
  5. Set the action's MenuGroup to IControlTheMenuGrouping/AtAllLevels.
  6. Inspect the rendered menu. Open IControlTheMenuGrouping, then AtAllLevels. The PersonSeeker action is inside this nested group.

Choose the ViewModel that opens

Under What the action does, Bring Up View Model identifies the ViewModel opened when the user invokes the GlobalAction.

  1. For PersonSeekerIAmInControl, verify that Bring Up View Model is PersonSeeker.
  2. Select the three-dot button beside the property. The ViewModel Editor receives focus and shows the selected ViewModel.
  3. Return to the action editor.
  4. Temporarily set Bring Up View Model to Index and use the three-dot button to verify that the editor now opens Index.
  5. Undo the test change so that the action again opens PersonSeeker.

In the rendered menu, use the ViewModel icon beside an action to open its ViewModel definition in MDriven Designer. Select the action text itself to select that GlobalAction in the action editor.

Add and order related actions

  1. Select Add Global Action.
  2. Set ActionName to PersonSeekerAgain.
  3. Set Bring Up View Model to PersonSeeker.
  4. Set MenuGroup to IControlTheMenuGrouping/AtAllLevels.
  5. Save and inspect the group in the running web application.

Use DividerGroupWithinMenu to create visual sections within the same menu group.

  1. Set PersonSeekerAgain DividerGroupWithinMenu to SomeName. Save and inspect the web application.
  2. Set PersonSeekerIAmInControl DividerGroupWithinMenu to the same value. Save and inspect the result.
  3. Set Sort order in the group to AAA on one action and BBB on the other.
  4. Save and verify their order in the web application.
  5. Swap AAA and BBB, save, and verify that the order changes.

Work with Class actions

A Class action belongs to a class. It is available for objects of that class where the ViewModel has matching type information. For example, an action for Person is available at a Person level, while an action for Car is available at a Car level.

Identify and rename a Person action

  1. Return to the PersonSeeker ViewModel and expand Actions.
  2. In Person-Nesting, find either of the two ShowPerson action links and open it.
  3. Inspect the action editor. The list contains Class actions for the Person class.
  4. There are two ShowPerson actions. One was copied when you adopted the ViewModel in the earlier chapter.
  5. Rename the action that does not bring up an autoform to ShowPersonIAmInControl.

Back in the ViewModel Editor, a Class action is identified by the class name in parentheses, for example ShowPersonIAmInControl (Person). Both actions belong to the Person class.

See how type context controls availability

  1. Change the class of the nesting from Person to Car.
  2. Ignore the temporary errors caused by this test.
  3. Observe that the Person actions disappear and a Car action, such as ShowCar, becomes available.
  4. Change the nesting class back to Person and save.
  5. Test both Person actions in the web application. They open different forms, and each form exposes the corresponding Class action that can take you to the other form.

This behavior is type-based: MDriven Designer shows Class actions when the current ViewModel level has the matching class context.

Opt a Class action in or out for a ViewModel level

Type matching usually gives the intended action placement. When you need to control whether a matching Class action is shown at a particular ViewModel location, use the action's opt-in settings.

  1. Open each Person Class action.
  2. At the top of its action definition, inspect the list of ViewModel locations whose type information matches the action's class.
  3. Ensure that the applicable levels are checked for both Person actions.
  4. Save and verify the result in the web application.

You can also control this from the ViewModel tree:

  1. In the ViewModel Editor, select the arrow in front of a Class action to opt it out at that location.
  2. Confirm the change in the web application.
  3. Use the ViewModel tree again to opt the action back in.

Work with ViewModelActions

A ViewModelAction, also called a ContextAction, belongs to a particular ViewModel rather than to a class. It can be placed at a selected level of that ViewModel tree.

Edit the delete confirmation

  1. Open the Person ViewModel.
  2. Expand Actions.
  3. Open the DeleteThis action.
  4. In the action editor, locate AreYouSure.
  5. Set it to Wow - wanna delete this person?.
  6. Save and test the action in the web application.
  7. When the confirmation appears, select Cancel so that you do not delete the Person while testing the prompt.

The left side of the ViewModelAction editor follows the ViewModel tree. It can also show matched Class actions. A true ViewModelAction has no class name in parentheses; a Class action does.

Limit the action to the intended ViewModel level

A ViewModelAction is not constrained by a class, so it can theoretically be available at multiple levels in its ViewModel. Use the level setting in the action editor to keep it where it makes sense.

  1. In the DeleteThis action editor, find the level setting at the upper right. It is initially set to Person.
  2. Change it to Car, save, and test the web application.
  3. Confirm that DeleteThis is now available only when a Car is selected.
  4. Change the setting back to Person and save. Deleting a Person from the Person level is the intended behavior for this example.

Place a button that invokes an action

A ViewModel button is a control placed in the ViewModel layout. It does nothing until you give it an action-language expression or connect it to an available action.

  1. Open the Person ViewModel in the ViewModel Editor.
  2. Add a button.
  3. Name its column DeleteMe.
  4. Save and inspect the web application. The button is visible but has no behavior yet.
  5. Find the button's Is action setting.
  6. Use the picker beside Is action to select DeleteThis from the actions available in this ViewModel.
  7. Save and test the button in the web application.

The DeleteMe button now invokes the existing DeleteThis ViewModelAction, including its confirmation text. This lets you place a familiar action where users need it without creating duplicate delete behavior.

Check your work

Before continuing, confirm that you can:

  • Open PersonSeeker from a GlobalAction in a nested menu group.
  • Use MenuGroup, DividerGroupWithinMenu, and Sort order in the group to control global-menu placement and order.
  • Recognize a Class action by its class name in parentheses and see it change with the nesting's type context.
  • Opt a Class action in or out at a ViewModel location.
  • Change a ViewModelAction confirmation message and restrict it to the correct ViewModel level.
  • Invoke DeleteThis through the placed DeleteMe button.

Next chapter

Continue with Training:Bootcamp:Chapter 6.

See also