Skip to content

Instantly share code, notes, and snippets.

@Pasquina
Created March 25, 2018 19:44
Show Gist options
  • Save Pasquina/31771a7e65b3404d6f4ffac6d3fbba89 to your computer and use it in GitHub Desktop.
Save Pasquina/31771a7e65b3404d6f4ffac6d3fbba89 to your computer and use it in GitHub Desktop.
LiveBindings Demo Data Module Constructor
{ The overridden constructor for the data module first creates the data objects that are
displayed by the view. This is done by creating the TCorp object which will cascade
through the TBranch and TEmployee objects to create the entire data tree. It is important
that the data objects be created BEFORE the data module (this form's) objects because the
OnCreate event for the TAdapterBindSource objects will need the data objects to function
properly. This is accomplished by creating TCorp FIRST, and then calling the inherited Create.
The inherited Create will actually create the objects in this TDataModule. }
constructor TMDLBO.Create(AOwner: TComponent);
begin
Corp := TCorp.Create( // Important: Create the data objects before anything else
'Acme Distributors', // these are
'5237 N Ravenswood Ave', // arbitrary values
'Chicago', // displayed by
'IL', // the view
'United States', // in the
'+1 312 555-5555'); // top banner
inherited; // now create the objects on this data module
end;
@Pasquina
Copy link
Author

Demonstrates how to ensure that the data objects are created before the actual DataModule objects are instantiated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment