Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

MVP Interactor ... how to link

16 views
Skip to first unread message

Stephane Fillon

unread,
May 1, 2005, 10:38:39 AM5/1/05
to
Bonjour Gurus,

I have read several times the previous posts and refact my framework to
move from MVC to MVP.

But I am not quite happy of what I have done... I am still missing some
parts. And I am very confuse on who create who...

This is what I have understood.


Presenter: the constructor take a Model (or BO) and a View.

The Model holds
- Selection
- CommandSet

The View
Can be a TForm, TEdit....
This mean that for TEdit for example.. I have to create an inherited
component TEditView which implement IMVPView, IStringValue, IOriginator...

The Presenter
- Model
- View
- Create the MainInteractor (to capture tabbing.... and set up the first
active Interactor).

Let's see an example:
---------------------

TCustomer = class(BO)
FirstName...
LastName...
end;


TCustomerModel = class(TMVPModel)
Selection
CommandSet -> SaveCommand, CancelCommand, CustomerUniqueCommand

end;


TCustomerView = class(TForm, IMVPView...)
FirstName: TEditView;
LastName: TEditView;
btnOk: TButton;
btnCancel: TButton;
end;


TCustomerPresenter = class(TMVPPresenter)
private
FView: IMVPView;
FModel: IMVPModel;
FMainInteractor: IMVPInteractor;
public
constructor Create(const pModel: IMVPMode; const pView: IMVPView);
end;

I have read that the Presenter create the nested Presenter.
In our example, TCustomerPresenter will create
TCustomerFirstNamePresenter and TCustomerLastNamePresenter ?
with LastName (VTF) and TEditView(LastName) with their MainInteractor.

If yes.. the MainFormValidator has to talk to a nestedPresenter ?

--
I have create a TButtonInteractor that link a Command (holded in Model)
to a TButtonView. It works ok.

--
For a control like TEdit... what parameters should I pass in the
constructor.
TEditInteractor.Create(const pModel: IMVPModel; const pView: IMVPView)
where pModel is the attribute (ex: LastName) and not the full Model..
and pView the TEditView.

I have try to handle the OnChange event.
The Interactor has it own OnChange: TNotifyEvent method and set it in
the TEdit (IEditView.SetOnChange()).

TEditInteractor.OnChange(Sender: TObject);
will read the string value using (View as IStringValue).GetValue

Am I right ??


I am sorry for all these questions... I have spent the last 2 weeks on
this and I still can't see the light... I am desesperate sniifff sniff :)


Stephane.

Joanna Carter (TeamB)

unread,
May 5, 2005, 7:10:39 AM5/5/05
to
"Stephane Fillon" <fill...@yahoo.com.au> a écrit dans le message de news:
4274...@newsgroups.borland.com...

> I have read that the Presenter create the nested Presenter.
> In our example, TCustomerPresenter will create
> TCustomerFirstNamePresenter and TCustomerLastNamePresenter ?
> with LastName (VTF) and TEditView(LastName) with their MainInteractor.
>
> If yes.. the MainFormValidator has to talk to a nestedPresenter ?

If I've got this correct, the main form's validator will be invoked from the
the TCustomerPresenter.Interactor (?) This then means that the validation
inside the Customer Presenter is aimed at validating the whole Customer,
through the Customer Model. IMO, it should not need to talk to the nested
presenters.

> I have create a TButtonInteractor that link a Command (holded in Model)
> to a TButtonView. It works ok.
>
> --
> For a control like TEdit... what parameters should I pass in the
> constructor.
> TEditInteractor.Create(const pModel: IMVPModel; const pView: IMVPView)
> where pModel is the attribute (ex: LastName) and not the full Model..
> and pView the TEditView.

I believe that this is the best approach.

> I have try to handle the OnChange event.
> The Interactor has it own OnChange: TNotifyEvent method and set it in
> the TEdit (IEditView.SetOnChange()).
>
> TEditInteractor.OnChange(Sender: TObject);
> will read the string value using (View as IStringValue).GetValue

I would tend to call the methods that are going to handle the edit events
with Handler at the end to avoid confusion.

procedure TEditInteractor.HandleOnChange(Sender: TObject);

> Am I right ??
>
> I am sorry for all these questions... I have spent the last 2 weeks on
> this and I still can't see the light... I am desesperate sniifff sniff :)

I'm sorry it took me so long to get back to you, your message got 'filed'
for later action. You seem to be getting the hang of things though :-)

Joanna

--
Joanna Carter (TeamB)

Consultant Software Engineer
TeamBUG support for UK-BUG
TeamMM support for ModelMaker


0 new messages