Write Back a Fragment Variable Value to the Parent Container

A fragment variable whose value is provided by the caller ("input": "fromCaller" property), can additionally be marked as supporting "writeback" ("writeback":true). This allows the fragment variable value to be automatically set / written back to the input parameter variable of the page. You can set the writeback property on fragment variables with the following types: primitive, array and object. If an input parameter value is already passed in by reference (for example, an SDP or $dynamicLayoutContext), the fragment variable receiving the reference doesn't need to be configured with the writeback property.

Example 1-52 Define the 'incidentId' interface variable in a fragment

In this example, a page uses the fragment below to provide a value for the variable via parameter.

"incidentId": {
  "type": "string",
  "description": "extensions can update the value",
  "input": "fromCaller",
  "writeback": true
}

When the fragment variable value changes, the value is automatically written back into the outer variable selectedIncidentId.

<oj-vb-fragment id="incs-list1" name="incidents-list">
  <oj-vb-fragment-param name="incidentId"
    value="{{ $page.variables.selectedIncidentId }}"></oj-vb-fragment-param>
</oj-vb-fragment>

Note:

The expression is wrapped in {{ }}. This is required for the web component framework to enable writeback.

As an alternative to the configuration above, the other recommended way for a page to be notified of updates to a fragment variable is for the fragment to fire a custom event (with the propagationBehavior property set to "container" ) that 'emits' the event to the page, which has a listener to handle the event. See Custom Fragment Events for details.