Consultor Eletrônico



Kbase 21253: ADM2: Instance Properties & How To Add Them In SmartObjects
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   16/10/2008
Status: Unverified

GOAL:

ADM2. How to use the instance properties for SmartObjects, how to add them to a SmartObject and how to set the instance property value during development using the SmartObject instance property screen.

FACT(s) (Environment):

Progress 9.x

FIX:

The instance properties are assigned to the SmartObject when it is executed.  

These properties are usually set at development time when the SmartObject is added to a SmartContainer.  

In order to set the instance properties, the SmartObject has an instance property screen -- select the 'Instance Properties' option in the SmartObject popup menu.
These instance properties values are saved and compiled in the 'adm-create-objects' internal procedure of the SmartContainer and can be changed in runtime.

The adm-create-objects execute the constructObject procedure as many times as there are SmartObjects in the container.  ConstructObject is an internal procedure of the containr.p super procedure.  This procedure receives the instance properties as input parameter.  Here is an example of how the adm-create-object executes the constructObject procedure:

RUN constructObject (
            INPUT  'adm2/dyntoolbar.w':U,
            INPUT  FRAME fMain:HANDLE,
            INPUT 'FlatButtons yes Menu yes ShowBorder yes Toolbar yes??..
            OUTPUT h_dyntoolbar).

RUN constructObject (
            INPUT  'dtables.w DB-AWARE':U,
            INPUT  FRAME fMain:HANDLE,
            INPUT 'AppService  ASUsePrompt  ASInfo  ForeignFields ???..
            OUTPUT h_dtables).

As shown in the example above, the instance properties are compiled and set when the container is executed.

When adding instance properties to a SmartObject the first step is to add the property in the ADMProps temp table.  To see how to add properties in the ADMProp temp table, see Progress Knowledge Base 21118. "ADM2-How To Add Static Properties In The ADMProps Temp-table".

After adding the property in the ADMProp temp table, this property must be declared as an instance property in the property file for the specified SmartObject.  The instances properties are defined in the xcInstanceProperties preprocessor variable.

Here is an example of how the instance properties of the dynamic toolbar are defined in the definition block of the adm2/toolprop.i file.

&IF "{&xcInstanceProperties}":U NE "":U &THEN
  &GLOB xcInstanceProperties {&xcInstanceProperties},
&ENDIF
&GLOB xcInstanceProperties {&xcInstanceProperties}~
FlatButtons,Menu,ShowBorder,Toolbar,ActionGroups,SubModules,TableIOType,SupportedLinks

The next example shows how the instance properties of the SDO are defined in the definition block of the adm2/dataprop.i file.

&IF "{&xcInstanceProperties}":U NE "":U &THEN
   &GLOB xcInstanceProperties {&xcInstanceProperties},
 &ENDIF
 &GLOB xcInstanceProperties

{&xcInstanceProperties}AppService,ASUsePrompt,ASInfo,ForeignFields,RowsToBatch,CheckCurrentChanged,RebuildOnRepos,ServerOperatingMode,DestroyStateless,DisconnectAppServer,ObjectName

In order to add a new property, the name of this property has to be added to the xcInstanceProperties preprocessor variable.  The next example demonstrates how to add the property, 'MyInstanceProperty', in the xcInstanceProperties preprocessor variable.

&IF "{&xcInstanceProperties}":U NE "":U &THEN
  &GLOB xcInstanceProperties {&xcInstanceProperties},
&ENDIF
&GLOB xcInstanceProperties {&xcInstanceProperties}~
FlatButtons,Menu,ShowBorder,Toolbar,ActionGroups,SubModules,TableIOType,SupportedLinks,MyInstanceProperty


Once the property is defined, the last step is to set the value of this property.  There are two ways to do it:

a) Setting the property in the container main block by executing the set<PropertyName> dynamic function.

or

b) Modifying the instance property screen for the SmartObject. The name of the instance property screen is defined in the same block as the xcInstanceProperties preprocessor variable. The name of this screen is defined in the ADM-PROPERTY-DLG preprocessor variable.  What follows is an example of how the instance property screen is defined f.or the dynamic toolbar:

/* This is the procedure to execute to set InstanceProperties at design time. */
&IF DEFINED (ADM-PROPERTY-DLG) = 0 &THEN
 &SCOP ADM-PROPERTY-DLG adm2/support/toold.w
&ENDIF

As seen in this example above, the toold.w file is the instance property screen for the dynamic toolbar.  When modifying this screen and adding the new instance property, the directory adm2/support should be created in the working directory, and the toold.w file should be copied in this directory in order to modify this screen..