From DSLs and Models to “Quadrant” using “Oslo” May CTP
"M" In a Nutshell
Modeling as Expressed in Code
What Exactly Does One Do With “Oslo”?To content | To menu | To search
Thursday 15 October 2009
By Steven Hillaert on Thursday 15 October 2009, 15:26
From DSLs and Models to “Quadrant” using “Oslo” May CTP
"M" In a Nutshell
Modeling as Expressed in Code
What Exactly Does One Do With “Oslo”?Tuesday 4 August 2009
By Steven Hillaert on Tuesday 4 August 2009, 16:07
ICanHandleView<TView>. This generic interface has
two methods, HandleView(TView view) and FillView(TView
view). FillView will be mostly called when the page is loaded to fill
the view with state information and HandleView will be called when an action
occurred (e.g. a button click). In the implementation of HandleView you take
the data from the view, store it in the controller and then decide to which
page you will redirect the user. So basically the Presenter is just there to
translate actions of the UI into calls to the controller.Presenter<T> where T is the interface of your view.
I've created a class BasePresenter that inherits from
Presenter<T>. BasePresenter has a property
Controller that returns a ICanHandle(TView), behind
the scenes this property uses a static class ControllerFactory
that creates a new controller or correlates the current request to an existing
controller. So, when WCSF created your presenter you just change the
Presenter<T> it inherits from with
BasePresenter<T>.ControllerFactory is
just a static class that will instantiate the real factory, in my case
WebControllerFactory. This was done to abstract the asp.net
infrastructure from the rest of the system as the
WebControllerFactory will use the HttpContext to do
the correlation.
WebControllerFactory is the
following:
Monday 27 July 2009
By Steven Hillaert on Monday 27 July 2009, 10:34
This is a compilation of my comments on the blog of Simon Ince concerning reusing views in the WCSF framwork. If there are more comments posted I will also update this article. Please feel free to share your ideas as well.
First of all, if you don't know WCSF check out the
articles on Simon's blog, you can find my comments on
part 2 of his series.
comment 1 (me)
First of all thanks for the great articles about WCSF!
But I do have a question:
How do you achieve reusing a view (.aspx page) in a different page flow (process)?
It seems to me that this is impossible in WCSF. The view receives the presenter from the system and the presenter receives the controller but I don't see any possibility to decide which controller to use. I have the impression everything is hooked up in the wrong order to achieve reusing a view in an other page flow. In WCSF a user browses to a page and so it's actually the view that decides which process (page flow) is started. Would the ASP.net MVC framework be better suited for this?
Steven Hillaert
comment 2 (Simon)
@ Steven,
that's a good question. I think it applies equally to the MVC framework as the WCSF - remember the Controller in MVC is not an "Application Controller". Instead the MVC is similar to MVP, so in fact the question is how do we decide which Application Controller (or any page flow implementation) to use from within the Presenter (in MVP) or Controller (in MVC)? I find it curious that not many people have discussed using an Application Controller in MVC yet.
Anyway, the issue you're referring to is that in the WCSF most people inject a controller into the presenter using a [CreateNew] attribute... but you needn't do it that way if you don't want to. You could instead inject a ControllerFactory of some form, and use that to create a Controller based on further metadata available to the Presenter (perhaps some session data, or a querystring argument). You could also use a Service Locator approach instead of injection to achieve the same thing.
The other way that view reuse can be achieved is to create a User Control with an MVP trio... although how you compose these can be a complex subject so give it a try and see if it fits your approach.
Does that help?
Make sure you check out Blaine's post & survey here and feedback if this needs further guidance;
Simon
comment 3 (me)@ Simon,
Concerning WCSF:
During the weekend I came to the same conclusions as you on how to implement
this in WCSF. I think the the querystring is the most flexible and practical,
the only problem I see with this is that the page could be "injected" into a
different process (pageflow) quite easily, some security will be needed here.
An other issue is that the controller will have to implement an interface for
every step (view) of the process because the presenter might used several
controllers that don't necessarily have the same interface.
Concerning MVC:
I had a quick look at it (reading) and I would think that reusing a view is a
lot easier here. The controller in MVC is a front controller, the user actually
"surfs" to the controller and not directly to a view. So you can make the user
surf directly to a process and then the process (controller) decides which view
to load.
Thanks for your help Simon, I will definitely take the survey and give feedback concerning this topic.
Steven
UPDATE
My implementation of a possible
solution.