Input Variables

Variables can also be inputs to the page.

There are two types of input. The first consists of inputs that come from the URL. The second type consists of inputs that are passed internally by the framework. To mark a variable as an input, you can use the following properties:

"nameOfVariable": {
  "type": "string",
  "input" "fromCaller/fromUrl"
  "required": true
}

Here the input is either "fromCaller" or "fromUrl". If it is "fromCaller", it will be passed internally using the params property of the navigate action. If it is "fromURL", it will be passed via the URL request parameter of the same name, like ?myVar=someValue. If the "required" property is true, the variable value will be required to be passed during a navigation or page load.

The implicit object $parameters is used to retrieve the input parameter values inside the vbBeforeEnter event handler. Input variables do not exist until the vbEnter event.

In this example, the input regionName is retrieved using $parameters.regionName in the vbBeforeEnter handler and using $page.variables.regionName in the vbEnter handler.

"eventListeners": {
  "vbBeforeEnter": {
    "chains": [
      {
        "chainId": "checkForRegionName",
        "parameters": {
          "regionName": "{{ $parameters.regionName }}"
        }
      }
    ],
  },
  "vbEnter": {
    "chains": [
      {
        "chainId": "initializeVariables",
        "parameters": {
          "regionName": "{{ $page.variables.regionName }}",
          "facilityId": "{{ $page.variables.facilityId }}"
        }
      }
    ]
  }
},