Groups > Borland > Delphi Object Oriented design > Re: Advice needed




Re: Advice needed

Re: Advice needed
Thu, 10 Apr 2008 14:30:24 +030
Eugene V. Goldberg wrote on 10/04/2008 :
> Hello,
>
> I hope this is a right NG, if not - i am sorry and please move 
> appropriately...
>
> I have a datamodule with dataset component and a form with UI data-aware 
> controls.
> There is a field "password" with corresponding TDBEdit, and TEdit
component 
> for
> "Password verification"...so this field is not bounded to any db
field...
>
> I do not want to reference a form and its controls from within the 
> datamodule...
>
> So what would be the proper way to implement a rule, that for new record
the 
> value
> of password field and a text entered in "Password verification"
field should 
> match?
>
> Thanx alot,
> Eugene.

place the check for in the form instead of the datamodule. After all it 
is there only to make sure that the user has keyed in correctly the 
password.

Regards
Yannis

-- 
Fill what's empty, empty what's full, and scratch where it itches.
    - the Duchess of Windsor, when asked what is the secret of a long 
and happy life

Post Reply
Advice needed
Thu, 10 Apr 2008 15:27:36 +040
Hello,

I hope this is a right NG, if not - i am sorry and please move 
appropriately...

I have a datamodule with dataset component and a form with UI data-aware 
controls.
There is a field "password" with corresponding TDBEdit, and TEdit
component 
for
"Password verification"...so this field is not bounded to any db
field...

I do not want to reference a form and its controls from within the 
datamodule...

So what would be the proper way to implement a rule, that for new record the 
value
of password field and a text entered in "Password verification" field
should 
match?

Thanx alot,
Eugene. 

Post Reply
Re: Advice needed
Thu, 10 Apr 2008 21:10:49 -040
I think a small Mediator Pattern with a Verify password function.

Let your data module be the Mediator and then add a procedure called


procedure TMyDataModule.RegisterPWVerify(AEdit: TEdit);
begin
  FPWVerify:= AEdit;
end;

procedure TMyDataModule.UnRegisterPWVerify;
begin
  FPWVerify:= nil;
end;

function TMyDataModule.VerifyPassword: Boolean;
begin
  if FPWVerify = nil then
    Result:= False
  else
    Result:= FPWVerify.Text = DataSet.FieldByName('Password').AsString;
end;


Your UI form could register and unregister the edit control in its create and
destroy methods.


TMyForm.MyFormCreate(Sender: TObject);
begin
  MyDataModule.RegisterPWVerify(Edit1);
end;

TMyForm.MyFormDestroy(Sender: TObject);
begin
  MyDataModule.UnRegisterPWVerify;
end;


Btw a nice side effect is that your data module *requires* user validation.


-Bill

Post Reply
about | contact