| Single-tier IntraWeb and RemObjects DataAbstract server |
|
|
|
| Written by Bernhard Fischer | ||||||||||
| Tuesday, 20 February 2007 | ||||||||||
Page 2 of 8 Let's give meaningful names to the auto-generated units/forms: the new application is saved as IWRODA.dpr, the datamodule is renamed to SessionDataModule and the application's main form now is called frmLogin, as it will provide login functionality before accessing any other services. The unit filenames are made identical to the new names in Delphi, but the first letter "u" is added. Now we save the server controller unit as uServerController.pas and rename it to ServerController. From your previous IW applications you know that you must manually adapt some lines of code after renaming units and after changing the auto-generated type declarations (changes are marked in the source code). In the project unit IWRODA.dpr: [click to collapse source code]
program IWRODA;
{PUBDIST}
uses
IWInitStandAlone,
uServerController in 'uServerController.pas' {ServerController: TDataModule},
uSessionDataModule in 'uSessionDataModule.pas' {SessionDataModule: TDataModule},
uFrmLogin in 'uFrmLogin.pas' {frmLogin: TIWAppForm};
{$R *.res}
begin
IWRun(TfrmLogin, TServerController);
end.
In the frmLogin unit: [click to collapse source code]
unit frmLogin;
{PUBDIST}
unterface
uses
IWAppForm,
IWApplication,
IWTypes;
type
TfrmLogin = class(TIWAppForm)
end;
implementation
{$R *.dfm}
uses
uServerController; // **renamed**
end.
In the ServerController's unit: [click to collapse source code]
unit uServerController;
{PUBDIST}
interface
uses
Classes,
uSessionDataModule, // **renamed**
IWServerControllerBase,
IWAppForm,
IWApplication,
SysUtils;
type
[...]
TUserSession = class(TComponent)
public
SessionDataModule: TSessionDataModule; // **renamed**
Username: string; // **added**
LoginTime: TDateTime // **added**
constructor Create(AOwner: TComponent); override;
end;
[...]
implementation
[...]
{ TUserSession }
constructor TUserSession.Create(AOwner: TComponent);
begin
inherited;
SessionDataModule := TSessionDataModule.Create(AOwner); // **renamed**
end;
[...]
As you have noticed, we also added a Username and a DateTime field to the TUserSession object. This is where we will store some values after the user has logged in. The UserSession is the right place to store client related information in a IW application. [click to collapse source code] unit uSessionDataModule; interface [...] implementation uses IWInit, uServerController, // **renamed** uGlobalDataModule; //**renamed** [...] function SessionDataModule: TSessionDataModule; begin Result := TUserSession(RWebApplication.Data).SessionDataModule; // **renamed** end; [...]
|
||||||||||
| Last Updated ( Friday, 18 January 2008 ) | ||||||||||
| Next > |
|---|


