Automatically Write Back a Fragment Variable's Value to Its Container Variable
When a fragment variable is enabled as an input parameter, you can mark it for writeback, allowing changes in the variable's value to be automatically written back to a variable on the fragment's parent container.
Let's say your employees page defines an empAvatar
variable, which takes a URL as its value. When this variable is passed as an input parameter to a fragment, the fragment receives it through an avatar
variable. This variable also has the option to write back to the container enabled. Assuming that the fragment is set up to update the employee's profile picture, when the avatar
variable on the fragment is updated to use a new URL, the change is written back to the outer page variable (empAvatar
). Depending on your setup, this might also update the table of employees where the new picture is shown in the currently selected row.
(To see an example of writeback in action, see the Passing Values To and From Fragments blog post.)
Writeback is supported for primitive (string, number, boolean, and any), array, and object type variables. Note that writeback is not required if an input parameter value is already passed in by reference (for example, an SDP or dynamicLayoutContext
).
To write back updates made to a fragment variable enabled as an input parameter: