Consultor Eletrônico



Kbase 21117: ADM2. Differences Between ADMProps and ADM-DATA
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   8/8/2006
Status: Unverified

GOAL:

ADM2. Differences between ADMProps and ADM-DATA

FACT(s) (Environment):

Progress 9.1x

FIX:

When working with multiple SmartObjects, it is usually necessary to handle properties between them. Dynamic properties using the ADM-DATA attribute and static properties using ADMProps temp-table are the two ways to store and handle properties in your SmartObjects. These two methods are used in Progress Version 9.x in place of the Version 8.x Set- and Get- Attributes.

It is recommended to use dynamic properties when a property is not used in each instance of a SmartObject. Otherwise the property name must be created at runtime. Dynamic properties are created in the ADM-DATA attribute at runtime. Other instances of the same SmartObject in the same application will not have this property.

-- Dynamic properties using the ADM-DATA attribute

In order to handle dynamic properties, Progress 4GL has the four dynamic-functions:

setUserProperty()
getUserProperty()
assignLinkProperty()
linkProperty.

setUserProperty("<propertyName>", "<propertyValue>")

This function receives the property name and the property value as parameters and sets it in the ADM-DATA attribute. Since the property name is a string, this name could be a variable, field value, object screen-value, etc.

getUserProperty("<propertyName>").

Returns the value for the property supplied as a parameter.

assignLinkProperty("<linkName>", "<propertyName>", "<propertyValue>")

Sets a property value through a link name. assignLinkProperty is useful when you don't have the target handle -- it sets the property to every object with the specified link. If it is necessary to set a property to each data-target for a specified SmartDataObject (SDO), the statement would be:

DYNAMIC-FUNCTION('assignLinkProperty':U IN h_dCust, 'data-target', 'propName', 'propValue').

linkProperty("<linkName>", "<PropertyName>").

Gets the property value through a link name. It returns the value of the property name through the link name supplied as the first parameter.


-- Static properties using ADMProps temp-table

Static properties are defined in the ADMProps temp-table. Each SmartObject has the ADMProps temp-table defined. Values for each property are initialized when the SmartObject is executed.
Examples of static properties are DataSource, ContainerSource, ASHandle, etc. By convention, to set or get the property's values, the words set or get must be added at beginning of the dynamic-property name as shown in these examples:

DYNAMIC-FUNCTION('setDataSource':u, INPUT <propValue>).

hHandle = DYNAMIC-FUNCTION('getDataSource':u).

Dynamic properties always return character values; static properties can return any type value.

Another way to set and get static properties is by using {set} and {get} include files. These include files check first if the property is defined in the ADMProps temp-table. If it's not already defined, the dynamic-function for the corresponding property will be executed. These examples show how {get} and {set} are used.

/*-----------------------------------------
Get the DataSource handle and store it in
The hHandle variable.
-----------------------------------------*/
DEFINE VARIABLE hHandle AS HANDLE NO-UNDO.

{get DataSource hHandle [target-handle]}


/*-------------------------
Set h_dCust as DataSource
-------------------------*/
{get DataSource h_dCust [target-handle]}

The optional target-handle parameter specified the SmartObject where the property will be set. It's the same as the phrase, 'IN <handle>' when using DYNAMIC-FUNCTION statements.