Add a Switch Action

You add a Switch action when you want to match a value against a set of values, in order to execute appropriate actions for that case.

For API information about this action, see Switch in the Oracle Visual Builder Page Model Reference.

To use a Switch action:

  1. Add the action in one of three ways, as explained at the end of Built-In Actions.
  2. For Value, hover over the far-right side of the property and click Select Variable to select the variable that is to be compared against each case value. If the value doesn't match any case value, or if it's null or undefined, the default case is executed.

    For example, when a menu defines a set of options, you can use the Switch action to determine which option was selected and to perform actions for that option. In this case, the page variable menuItemId holds the selected menu option, and it's selected using the Switch action's Value property:
    Description of jsac-switch-action.jpg follows
    Description of the illustration jsac-switch-action.jpg

  3. To define a case:
    1. Set a value for the case by selecting it within the Switch action, then using the Value property to enter its value or to select the variable that holds it. To select a variable, hover over the properties far-right side and click Select Variable.

    1. Drop the actions to execute for the case in the Add Action area of the case block and configure their properties in the Properties pane:

    1. If the rest of the cases are to be ignored, select Break after. If not selected, the rest of the cases get executed, regardless of their values, until running into a break statement (if at all).
  4. To add a new case block, right-click a case and select Duplicate: