Consultor Eletrônico



Kbase P95519: How to return selected data from a SmartDialog which contains a SmartDataObject and a SmartDataBrows
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   9/27/2005
Status: Unverified

GOAL:

How to return selected data from a SmartDialog which contains a SmartDataObject and a SmartDataBrowser

FIX:

The following code fragments show how to build a SmartDialog which does the following:

Uses OUTPUT parameters to return information back to the caller
Contains a SmartDataObject which is used as the data source
Contains a SmartDataBrowse which the user uses to select the desired record
Allows the user to double-click a row in the SmartDataBrowse with the mouse to select that record
The following code fragments assume that you have already created a SmartDialog, SmartDataBrowser and SmartDataObject:
1) Open the SmartDataBrowse in the AppBuilder.
2) Add a trigger for the LEFT-MOUSE-DBLCLICK event of the browse widget.
3) Add the following code to the trigger:

DEFINE VARIABLE hParentFrame AS HANDLE NO-UNDO.
ASSIGN hParentFrame = DYNAMIC-FUNCTION('getObjectParent').
APPLY 'GO' TO hParentFrame.
4) Save the SmartDataBrowse.
5) Open the SmartDialog in the AppBuilder.
6) Add the SmartDataObject to the SmartDialog.
7) Add the SmartBrowse to the SmartDialog.
8) Add however DEFINE OUTPUT PARAMETER statements are needed to the Definitions section of the SmartDialog.
9) Add the following code to the destroyObject procedure before the RUN SUPER statement:

/*
Fetch The Requested Values From The SDO Before We Destroy Any Objects,
However, Only Do This If The User Did Not Hit Escape Or Press The
Cancel Button (i.e. LAST-EVENT:FUNCTION Is Not Equal To 'ENDKEY').

Note That By Doing Things This Way We Do Not Need To Worry About Doing
A PUBLISH/SUBSCRIBE Scenario (Which Can Be Problematic When Multiple
Batches Of Records Need To Be Fetched From The SDO In Order To Select
The Correct Record In The SmartDataBrowser). The Only Code That Needs
To Be Added To The SmartDataBrowser Is To Handle The Double-Click
Event And Even Then All We Do Is Get The Handle To The Parent Frame
And Then Simply Apply 'GO' To It.

Note That The 'ELSE' Block Below Which Assigns The Unknown Value To
The Output Parameters Would Not Be Needed If You Used 'INITIAL ?' On
The Parameter Variable Definitions In The 'Definitions' Section. We
Went Ahead And Added This Code To Ensure That What Was Happening Was
Clear.
*/
IF LAST-EVENT:FUNCTION <> 'ENDKEY' THEN
ASSIGN vOutputParameter = DYNAMIC-FUNCTION('columnValue' IN h_YourSDOGoesHere, 'YourFieldNameGoesHere').
ELSE
ASSIGN vOutputParameter = ?.
10) Save the SmartDialog.
The SmartDialog is now ready to be run from within your application. If the user presses the ESCAPE key or clicks the Cancel button all output parameters should return the unknown value.