Skip to content

WebGet

See Also: WebSet, Get, Set

Purpose

Retrieves the value of a Web Property.

Syntax

WebGet
    PropertyName [of Object] to Variable

Argument Explanation

  • PropertyName: The name of the web property whose value to retrieve.
  • Variable: The variable to retrieve the value of PropertyName into.

What It Does

For a web application to perform useful work, it is necessary to have persistent data that can be accessed from one server call to the next. This is accomplished using web properties.

Web Properties can be of type Client, Server, or ServerSession.

  • A Client Web Property is sent to the client and can be used by the JavaScript engine. Since a property is sent to the server each time a server call is performed (i.e., each time an action or event is triggered on the server by the client), it means Web Properties can be considered persistent data from a given client, server, or session instance. If a web property is changed on the server (using WebSet), then this changed value is passed back to the client. Client Web Properties are synchronized to a single client session while a server call is being processed from that client. At any other time, Client Web Properties should be considered out of scope, since there is no way of knowing to which client session (if any) they are synchronized.

  • A Server Web Property is attached to the page scope (clears when the page is reloaded). Its value stays on the server and is not accessible on the client. Server Web Properties are not sent to the client and are stored on the server to provide persistence until the next request from the client comes in. The goal of Server Web Properties is to provide an easy and secure method to store the application state without information being sent to the client. In addition to security, they can also improve performance when compared to Client Web Properties.

  • A ServerSession Web Property is attached to the session (expires together with the session). Its value stays on the server and is not accessible on the client.

Web Properties support all data types, with the exception of:

  • The RowId data type is not supported in web properties, including structs and arrays. If you need to store RowIds, serialize them to a string using the SerializeRowId() function.
  • Multidimensional arrays are not supported as web properties, but they can be used as a member of a struct.

For more information about Web Properties, see Web Properties.

Declaring Web Properties

A property is declared as a Web Property via the WebProperty Meta Data Tag. Only properties of the cWebObject class (or a subclass) can be tagged as Web Properties.

You cannot WebGet or WebSet a property unless it is defined as a Web Property.

This declares a property as a Client Web Property:

{ WebProperty=Client }
Property String psLabel ""

This declares a property as a Server Web Property:

{ WebProperty=Server }
Property String psLabel ""

This declares a property as a Server Session Web Property:

{ WebProperty=ServerSession }
Property String psLabel ""

Example

To access the current value of the psValue property of a cWebForm after a user in a specific client session has changed that value, you must use WebGet.

Correct:

Procedure DoSomething
    String sValue
    WebGet psValue of oWebForm1 to sValue
End_Procedure

If you were to use Get instead of WebGet, you would retrieve the initial value of the property, rather than the current value of that property in the running client session.

Wrong:

Procedure DoSomething
    String sValue
    Get psValue of oWebForm1 to sValue
End_Procedure

Note

WebGet does not delegate. If you are in a child object and need to access a property of a parent object (e.g., cWebView) via WebGet, you must use the object name to WebGet the value:

WebGet psValue of oMyWebView to sValue

To view the current value of a Web Property in the Studio's Watches Window, use the _WP debugger function.