Tips & Tricks - WriteContainer - Reading a Value from the Session

This article explains how values from a WriteContainer can be written to a session and then read back into another WriteContainer. You can download the sample application here and then import it as usual.

In the application, a value can be entered in the "write-session" input field on the input page. When saved, this value is written to the session by a properly configured WriteContainer and entered into "Title" by a second WriteContainer.

Elements on the input page

On the input page of the sample application, you'll find the "write-session" input field, the contents of which are to be written to the session.

The input field is linked to a data field. All other elements on the input page are those that are created automatically when you create an application using the " Basic Application " application template.

WriteContainer "WRITE_SESSION"

To write the value of the "write-Session" input field to the session, a WriteContainer was created with the name "WRITE_SESSION," the type "User-defined," and the user-defined class "Session." This WriteContainer is positioned as the first WriteContainer in the sequence. In this example, nothing needs to be defined in the WriteContainer's filter criteria.

In the bindings, the source "Control," the control "write-session," and the session variable "my_session_var" are defined as the destination.

WriteContainer "WRITE_XDATAGROUP00D1A218"

The second WriteContainer is the default WriteContainer, which is automatically created when you create an application using the " Basic Application " application template. The settings in the Properties and filter criteria can be left as they are here.

You'll find two entries in the bindings of the second WriteContainer.

The first binding reads the session variable and writes it to the "Title" field. The settings are as follows: Source "Session," Session "my_session_var" (name of the session variable), Destination "Title" (data field linked to the "Title" input field on the input page).

The second binding ensures that the session value is also stored in the "write-session" data field. Here are the settings: Source "Control," Control "write-session" (name of the input field), Destination "write-session" (data field linked to the "write-session" input field on the input page).

"OK" button

In the properties of the "OK" button, all you need to do now is add the "WRITE_SESSION" WriteContainer on the "Actions" tab.