Consultor Eletrônico



Kbase 20138: ADM2 - Easy Method for Invoking Code in Another SmartObject
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   02/09/2008
SUMMARY:

Progress customers often create code similar to the following so that they can invoke an internal procedure in another SmartObject:

DEFINE VARIABLE cObject AS CHARACTER NO-UNDO.
DEFINE VARIABLE hObject AS HANDLE NO-UNDO.

ASSIGN cObject = DYNAMIC-FUNCTION('linkHandles', 'SomeLink-Target')
hObject = WIDGET-HANDLE(cObject).

RUN SomeProcedure IN hObject.

However, there is a much easier way to accomplish this.

EXPLANATION:

The key to this easier method is the fact that when you create a custom SmartLink between two SmartObjects (not one of the standard link types) the ADM2 will automatically issue a SUBSCRIBE in the link target for the custom link type.

For example, if you have two SmartObjects (SMO-A and SMO-B) and SMO-B has an internal procedure named 'SomeProcedure' which you want to invoke from SMO-A, the following steps accomplish this:

1) Create a SmartLink named 'SomeProcedure' where SMO-A is the
source and SMO-B is the target.

2) In SMO-A, place the following line of code at the point where
you want to invoke the internal procedure in SMO-B:

PUBLISH 'SomeProcedure'.

The advantages to using this method to invoke internal procedures in other SmartObjects are:

1) Less code required in the source SmartObject.

2) Does not tightly couple two SmartObjects together.
Code is more easily reusable.

3) One source SmartObject can link to multiple target
SmartObjects and invoke an internal procedure in each of them
with only one line of code.

4) No need to explicitly handle cases where links do not exist or
internal procedure does not exist.