Smart Repository Form De-activate Datasources

Smart Component Library Smart Repo version from Release 11.3 #54622@2019-09-30.
Basic knowledge of the Smart Repository functionality of the Smart Component Library.

Issue Description.

A repository based Form Datasources which are linked to browsers.
At the initial start of the Form we may not want all the Datasources to be loaded with the data.
When all the Datasources are filled with data it will slow down the startup time of the Form.

Resolution.

In a Smart Repository object of type MetaForm there is an attribute called LogicObject.
In this attribute the FormLogic object class name is set.

In this FormLogic class you can add logic for the Form; this includes also the logic for solving this issue.


You will have to perform the following steps:

  1. Create a FormLogic class for the Form;

  2. In the FormLogic create two override classes Initialize and SubscribeEvents;

  3. Initialize the SmartBusinessEntityAdapterInstance in which you do not want to load the data at the start;

  4. Set the SmartBusinessEntityAdapter Inactive;

  5. Initialize a tabfolder object to handle the tabchange event;

  6. Subscribe to the ActiveTabChanged event of the tabfolder object;

  7. Create the subscribed ActiveTabChangedHandler method.

1. Create FormLogic class for the Form.

We Assume you known how to do this.


2. In the FormLogic class create two override classes, Initialize and SubscribeEvents.

We Assume you known how to do this.

3. Initialize the SmartBusinessEntityAdapterInstance where you do not want to load the data at the start.

The SmartBusinessEntityAdapterInstance(s) have to be initialized in the SubscribeEvents method of the FromLog class.
For example:
THIS-OBJECT:CustomerBusinessEntityAdapter = THIS-OBJECT:GetSmartBusinessEntityAdapterInstance ("CustomerDataSource ":U).

4. Set the SmartBusinessEntityAdapter Inactive.

In the SubscribeEvents method.
For example:
THIS-OBJECT: CustomerBusinessEntityAdapter:SmartDataSourceActive = FALSE.

5. Initialize a tabfolder object to handle the tabchange event.

The UltraTabControlInstance has to be initialized in the SubscribeEvents method of the FromLog class.
For example:
THIS-OBJECT:Tabfolder = THIS-OBJECT:GetUltraTabControlInstance ("TabFolder":U).

6. Subscribe to the ActiveTabChanged event of the tabfolder object.

In the SubscribeEvents method.
For example:
THIS-OBJECT:Tabfolder:ActiveTabChanged:Subscribe (ActiveTabChangedHandler).

7. Create the subscribed ActiveTabChangedHandler method.

To handle the tabfolder ActiveTabChanged event create the ActiveTabChangedHandler method.
Set the SmartBusinessEntityAdapter to Active.
Before that beware to set all other possible SmartBusinessEntityAdapters to Inactive otherwise they will be filled again after changing the row of the primary Browser.
For example:
METHOD PUBLIC VOID ActiveTabChangedHandler (sender AS System.Object, e AS ActiveTabChangedEventArgs):

CustomerBusinessEntityAdapter:SmartDataSourceActive = FALSE.

CASE e:Tab:Key:

WHEN "Customer":U THEN

CustomerBusinessEntityAdapter:SmartDataSourceActive = TRUE .

END CASE.

END METHOD.