Using Scope(*Shared)

LANSA

Using Scope(*Shared)
Example 201 - Rating: advanced
The Things that Make Up this ExampleTo Execute this Example

This example demonstrates some of the essential concepts involved in using the Scope(*Shared) option in RDMLX code. The example form (S_201FMF) looks like this:



On the left hand side of the main form are three instance of reusable part named S_201RSA. Each S_201RSA instance acts as a simple list editor. You can type values into the entry field at the bottom of the list and add them to the list by using the Add button. Similarly existing entries in the list can be updated by selecting them, editing the value in the field at the bottom of the list and then using the Update button.

The S_201RSA components use another component named S_201RSO to manage (i.e.: control) their lists for them. They add to and update entries in the list by invoking methods in S_201RSO. They are also notified (i.e.: signaled) by S_201RSO whenever the list changes (i.e.: entries are added or updated).

Conceptually, the three active instances of the S_201RSA editors and S_201RSO list managers could be visualized like this:



On the right hand side of the main form are three instances of reusable part named S_201RSB. S_201RSB acts as a simple list editor just like S_201RSA does. In fact, the RDMLX code in S_201RSB is identical to S_201RSA, except for the way that the list manager is defined. It is defined like this:


DEFINE_COM CLASS(#S_201RSO) NAME(#TEXT_MANAGER) SCOPE(*Shared)

This indicates that all the active S_201RSB components should share a single instance of the list manager S_201RSO.

This sharing of S_201RSO radically effects the way that the S_201RSB list editors behave (compared to the nearly identical S_201RSA versions) and it demonstrates how "manager" or “controller” style shared components can be used to broadcast information to many other components.

Conceptually, the three active instances of the S_201RSB editors and S_201RSO list manager could be visualized like this:





Keywords
Example 201Shared
ReusableScope