Loading Data
The first thing you need to do is to actually get some data from the Relativity Server. You will start by getting the data for the Tasks table.
The Main Form
Before writing the code to get the data, add a TButton
and a TDBGrid
to the main form.
Add an onClick
event handler to the Load Data button and set it to call the loadData
method of the DataModule.
//fClientForm.pas
procedure TClientForm.btnLoadClick(Sender: TObject);
begin
ClientDataModule.loadData();
end;
Also connect up the TDBGrid
to use the ds_Tasks
datasource from the DataModule.
The DataModule
In the DataModule, implement the loadData
method to simply open the tbk_tasks
component.
//fClientDataModule.pas
procedure TClientDataModule.LoadData;
begin
tbl_Tasks.Close;
tbl_Tasks.Open;
end;
First Run
Run the application now. When you press the Load Data button, if everything is wired up right, it should first ask you to log in. Use Daniel/222 from the test data.
Opening the tbl_Tasks
component would have triggered a request to the Relativity Server, which in turn triggers the Login process. If you are running in debug mode, you will get an exception dialog with a SessionNotFoundException
. This exception is thrown when the server requires a login and doesn't have one.
Once you have logged in, you should see all the data in the Tasks table.
The DataAbstract components have handled all the complexity behind retrieving the remote data and left you the simple task of opening the table, just as if it were connected to a local database.