Kbase P33894: How to send a context property to the server side using SmartDataObjects
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  7/11/2006 |
|
Status: Unverified
GOAL:
How to send a context property to the server side using SmartDataObjects
GOAL:
How to add a property to the context list
GOAL:
How to use a context property in the server side
FACT(s) (Environment):
Progress 9.1D
FIX:
Some times is needed to send some properties to the server side to be used, for example in the beginTransactionValidate. In this kind of procedures the property value cannot be sent as parameter.
The following is an example of how to use the context list to send a property to the server side and use it in a validation procedure.
NOTE: All of the customization is done in the SmartDataObject.
1- Define a variable in the definitions block (i.e.: myProperty).
2- Create the set function for the variable:
FUNCTION setMyProperty RETURNS LOGICAL
( INPUT pcValue AS CHARACTER) :
/*------------------------------------------------------------------------------
Purpose:
Notes:
------------------------------------------------------------------------------*/
ASSIGN myProperty = pcValue.
RETURN TRUE. /* Function return value. */
END FUNCTION.
3- Define the get property for the variable:
FUNCTION getMyProperty RETURNS CHARACTER
( /* parameter-definitions */ ) :
/*------------------------------------------------------------------------------
Purpose:
Notes:
------------------------------------------------------------------------------*/
RETURN myProperty. /* Function return value. */
END FUNCTION.
4- Override the genContextList in the SmartDataObject as the following example:
PROCEDURE genContextList :
/*------------------------------------------------------------------------------
Purpose: Super Override
Parameters:
Notes:
------------------------------------------------------------------------------*/
DEFINE OUTPUT PARAMETER pcContext AS CHARACTER NO-UNDO.
/* Code placed here will execute PRIOR to standard behavior. */
RUN SUPER( OUTPUT pcContext).
/* Code placed here will execute AFTER standard behavior. */
/*Adds the new property to the context list*/
ASSIGN pcContext = pcContext + CHR(3) + "myProperty" + CHR(4) +
DYNAMIC-FUNCTION("getMyProperty").
END PROCEDURE.
After this steps the property value can be set in the client side using the following line:
DYNAMIC-FUNCTION('setMyProperty':U IN <sdo-handle>, INPUT 'newValue').
The function will be set in the client side, and then sen to the server by the genContextList procedure in the next request. The SDO server side sets to itself all of the properties sent in the getContextList.
In the server side this property could be get using the following line:
DYNAMIC-FUNCTION('getMyProperty').