Tips & Tricks - WriteContainer - Read value from session
This workshop demonstrates how values of a WriteContainer can be written to a session and then read in another WriteContainer.
The example application can be downloaded here and imported into your portal as usual. On the edit page of the application, a value can be entered in the "write-session" edit field. When the user clicks on "Save", this value is saved to the session by an appropriately configured WriteContainer and then entered into the "Title" field by a second WriteContainer.
Elements on the edit page
The edit page of the example application contains an edit field called "write-session"; its content will be written to the session.
The edit field is linked to a data field. All other elements on the edit page are the elements that are created automatically when you create a new application based on the Basic application template.
To write the value of the "write-session" edit field to the session, a WriteContainer with the name "WRITE_SESSION", the type "Custom" and the user-defined class "Session" has been created. This WriteContainer is first in the order of the WriteContainers. Nothing needs to be defined in the filter criteria of the WriteContainer in this example.
Under "Bindings", the source is set to "Control", "write-session" is the selected control, and the session variable "my_session_var" is defined as the target.
The second WriteContainer is the standard WriteContainer that is automatically created when an application is created based on the Basic application template. The settings under "Properties" and "Criteria" can be left as they are in this case.
You will find two entries under "Bindings" of the second WriteContainer.
The first binding reads the session variable and writes it in the "Title" field. The settings here are: Source "Session", Session "my_session_var" (name of the session variable), Target "Title" (data field linked to the "Title" edit field on the input page).
The second binding ensures that the session value is also stored in the "write-session" data field. The settings here are: Source "control", control "write-session" (name of the edit field), target "write-session" (data field linked to the "write-session" edit field on the input page).
All that is left is to add the "WRITE_SESSION" WriteContainer on the Actions tab of the properties of the "OK" button.