type
TForm3 = class(TForm, IObserver)
Button1: TButton;
Edit1: TEdit;
ListBox1: TListBox;
Button2: TButton;
Button3: TButton;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
procedure UpdateView (obj : TObject);
end;
...
procedure TForm3.Button1Click(Sender: TObject);
var
c : TCommand;
o : TCommandParam;
begin
c := TCommand.Create ('SEARCH');
o := TCommandParam.Create;
o.Name := edit1.Text;
c.AddParam(o);
Controller.DoCommand(c);
end;
procedure TForm3.Button2Click(Sender: TObject);
begin
ModalResult := mrOK;
end;
procedure TForm3.Button3Click(Sender: TObject);
begin
ModalResult := mrCancel;
end;
procedure TForm3.FormCreate(Sender: TObject);
begin
Controller.AddView (self);
end;
procedure TForm3.UpdateView (obj : TObject);
var
val : String;
begin
// Update the view here
if ((obj as TDomainModel).ClientSearchResult <> nil) then
begin
for val in (obj as TDomainModel).ClientSearchResult do
begin
ListBox1.AddItem(val, nil);
end;
end;
end;
I have merge the View classes with the actual form, in order to make the code relationships a little clearer.
I'm really happy with all of the, and I think it will be applicable for the requirements I have at work.
No comments:
Post a Comment