WebProperty Meta-Tag

Used to declare a property of a web object as a web property.

Web Properties are mainly used to define data that are sent to the client for each web object. Only subclasses of the cWebObject class understand the web property interface.

The web property system also supports server web properties. These properties are not sent to the client and are stored on the server to provide persistency until the next request from the client comes in. Server properties provide an easy and secure method to store the application state without information being sent to the client. Because they reduce the amount of data sent between the client and server they can also improve performance when compared to client-side web properties.

The default server properties are bound to the page scope which means that they will live just as long as client web properties (until the page is reloaded/left). Also available are ServerSession properties that are bound to the session and will be accessible until the session expires.  

How to use Web Properties

Web properties are accessed using WebGet and WebSet. Set and Get can be used to access the initial value when a session is initialized. The WebProperty meta tag uses Client, Server and ServerSession settings. It also supports a True setting for backwards compatibility with web classes from prior revisions of DataFlex.

{ WebProperty=Client }

This signifies a client-side web property. Its value is sent to the client and can be used by the JavaScript engine.

{ WebProperty=ClientProtected }

This signifies a client-side web property, but its value is also stored on the server (like a Server Web Property).

{ WebProperty=Server }

This signifies a server-side web property attached to the page scope (clears when the page is reloaded). Its value stays on the server and is not accessible on the client.

{ WebProperty=ServerSession }

This signifies a server-side web property that is attached to the session (expires together with the session). Its value stays on the server and is not accessible on the client.

{ WebProperty=True }

The True value is deprecated. It works the same as { WebProperty=Client } to maintain backwards compatibility.

 

Examples

The psLabel property is understood by all web controls. The declaration for psLabel is as follows:

{ WebProperty=Client }

Property String psLabel ""

If an object sets the psLabel property...

Object oName is a cWebForm

    Set psLabel to "Name:"

End_Object

Then the value of the psLabel property (“Name:”) is sent to the client when that object’s view is loaded.

Normally, the client object handles each web property that is sent to it and will perform defined actions according to their values. If a web property is sent to the client that the client object does not know, then its value is simply stored in the client object. This means that you can declare your own web properties and use them to store values at the client. For example:

Object oClicker is a cWebButton

    { WebProperty=Client }

    Property Integer piCountClick 0

End_Object

In this example, the name-value pair piCountClick=0 is sent to the client when that object’s view is loaded.

 

WebAppServerProps Table

Server web properties are stored in the database in the ‘WebAppServerProps table. By default this is an embedded table but it is advised to convert this table to the database being used by the rest of the application. It is advised to increase the size of the data field when the database allows this. When converting to MS SQL the conversion wizard will automatically change the field into a varchar(max) field with a DataFlex size of 1 MB.

The table contains an ExpiresDate field that can be used for automated cleanup of the data as the framework will not delete records by itself. It is advised to schedule a job inside SQL server to do this.

When to use server properties?

In general every web property can become a server property as long as there is no JavaScript that relies on it. So if a web property is created within an application without JavaScript being added that uses it then it is advised to make this a server web property. The performance of server properties will depend on the amount of data stored in them but in general they are expected to be faster as client web properties.

Studio Support for Server Properties

The Studio automatically adds the WebAppServerProps table to a workspace the first time a web application is created in a workspace (along with the WebAppSession and WebAppUser tables). For workspaces that were created prior to DataFlex 19.0 (or don't have the WebAppServerProps table for any reason), the table is automatically added whenever the JavaScript Engine is updated.