| Single-tier IntraWeb and RemObjects DataAbstract server |
|
|
|
| Written by Bernhard Fischer | ||||||||||
| Tuesday, 20 February 2007 | ||||||||||
Page 6 of 8 Now that we completed the background processing, we have to create the web forms to receive the parameters and show the results. First we drop some IW components on the Login form:
Now create a new IW application form with the Delphi wizard. This will become our content form to be shown after the user logged in. please correct the auto-generated uses clause immediately! change uses ServerController; to
We rename the components: dataStreamer, remoteAdapter, tableUsers and dsUsers .
Linking the components is business as usual: gridUsers.DataSource: dsUsers dsUsers.DataTable: tableUsers tableUser.Logicalname: USERS tableUser.RemoteDataAdapter: remoteAdapter remoteAdapter.DataStreamer: dataStreamer Set gridUsers ' property Visible to False . Now include the units uSessionDataModule , uServerController and SysUtils in the uses clause. In our frmContent's OnCreate event, link the remoteAdapter's property RemoteService to the UserSession's SessionDataModule.serviceRemote . (see the following code box). The SessionDataModule is available at runtime after a client connected. Because we encapsulate our client-related stuff in a per-session manner, the application remains thread-safe. This is the complete unit for our content form. Please implement all events to have a working example. [click to collapse source code]
unit uFrmContent;
{PUBDIST}
interface
uses
IWAppForm,
IWApplication,
IWTypes,
Classes,
Controls,
IWControl,
IWCompLabel,
uDADataStreamer,
uDABinAdapter,
DB,
uDADataTable,
uDAScriptingProvider,
uDACDSDataTable,
IWGrids,
IWDBGrids,
IWCompButton,
uDARemoteDataAdapter,
IWHTMLControls;
type
TfrmContent = class(TIWAppForm)
labelHello: TIWLabel;
labelTime: TIWLabel;
buttonShow: TIWButton;
gridUsers: TIWDBGrid;
linkQuit: TIWLink;
dataStreamer: TDABinDataStreamer;
remoteAdapter: TDARemoteDataAdapter;
tableUsers: TDACDSDataTable;
dsUsers: TDADataSource;
procedure IWAppFormRender(Sender: TObject);
procedure IWAppFormCreate(Sender: TObject);
procedure buttonShowClick(Sender: TObject);
procedure linkQuitClick(Sender: TObject);
end;
implementation
{$R *.dfm}
uses
SysUtils,
uServerController,
uSessionDataModule,
IWForm;
procedure TfrmContent.IWAppFormRender(Sender: TObject);
begin
labelHello.Caption := 'Hello ' + UserSession.Username;
labelTime.Caption := 'Your login time was ' + DateTimeToStr(UserSession.LoginTime);
end;
procedure TfrmContent.IWAppFormCreate(Sender: TObject);
begin
remoteAdapter.RemoteService := UserSession.SessionDataModule.serviceRemote;
end;
procedure TfrmContent.buttonShowClick(Sender: TObject);
begin
tableUsers.Open;
gridUsers.Visible := True;
end;
procedure TfrmContent.linkQuitClick(Sender: TObject);
begin
WebApplication.Terminate('That''s it!');
end;
end.
Note that the two labels on the content form are filled in the OnRender event with values from the UserSession - values we filled with our RO services before. What is left over, is the first form in our application - the Login form. Make sure to include our library interface file IWRODALibrary_Intf.pas in the uses clause, because we will access the LoginService from this login form. We also need the uSessionDataModule unit included to connect to the services. Insert the unit uFrmContent in the upper, interface uses clause, beacuse we need it in our type declaration. Note the public field frmContent in the TfrmLogin declaration. Remember, we can't use global variables. Our login unit's OnCreate event is also a good place to create the content form above - the user will see next after authentication. |
||||||||||
| Last Updated ( Friday, 18 January 2008 ) | ||||||||||
| Next > |
|---|


