State Management Mechanisms

The stateless nature of the HTTP protocol means that Uniface server pages are stateless and must explicitly implement state management using one or more of the available state management mechanisms.

No matter which mechanism is used to maintain state, minimum context information such as a session ID must be passed between the browser and the server to identify the rest of the state information. By default, the minimum state information is passed as a cookie to a browser.

The postActivate and preActivate triggers contain default code for setting and retrieving state information, but you can elaborate this code to suit your preferences, state mechanism, and security requirements.

State Management Mechanisms
State Management Mechanism Description More Information
Cookies Small files attached with the HTTP response and request for keeping state information. Uniface provides an automatic cookie mechanism for you to maintain state.

Using cookies requires less processing and fewer resources than maintaining state in tables because it is also not necessary to start a database session to store or restore state information. However, some Web servers have limitations on the size of a cookie and some browsers may be configured to not accept cookies.

Uniface Cookies
Temporary files Temporary files for keeping state information. You can use the filedump and fileload ProcScript statement to store and retrieve state information.

It is only suitable for keeping simple state information. For complex data, it is better to use temporary database tables.

Temporary Files and Tables for State Management
Temporary tables Database tables for maintaining state information. This approach is suitable for maintaining a large amount of data.

Uniface provides an automatic temporary-table mechanism for you to maintain state through its state management component USYSSTAT.

Using Default Temporary Tables to Maintain State
URL-based state management URL followed by a context information.

For USPs, if browsers are configured to not allow cookies, you can specify the session ID as a URL query string, or dynamically choose to use either a cookie or a URL depending on the browser.

Note:  URL-based state management is not supported for dynamic server pages.

Uniface URL-Based State Management
Hyperlinks Similar to URL-based state management, but used to pass context information and parameters between different server pages. This technique is generally used in static server pages to go from an index page to a detail page.

In a non-Web application, context information can be passed from one component to another through operation parameters. This is inapplicable for static web applications because operations called through a URL cannot have parameters defined in the component signature.

In web applications, the user context information is placed into the query string part of the URL following the question mark (?) and can be interrogated using $webinfo. A list can also be passed in the query string by separating items in the list with ampersands (&).

Calling Operations on Static Server Pages
Hidden fields Fields contained within the HTML code that are not displayed in the browser. You can save the state information into the hidden fields before the component is destroyed, and get them from the hidden field when dealing with next request.

Hidden fields are suitable for a small amount of state information.

Creating Hidden Fields
Authentication A mechanism of identifying users for access control.

This mechanism can also be used to trace user information. Once a user has been authenticated for a particular set of resources, the user name and password are available for the duration of the session until the browser window is closed. Combined with the temporary table mechanism, this user information can be used to identify which state-information record belongs to which user.

Authentication for Uniface Web Applications

Related Topics