Speaking of our noddy MVC framework, it's all coming together now.
The bleedin' obvious stuff: we have a
Controller servlet, to which all
*.command URLs map. The
Controller loads up a
Map when it starts up, mapping URLs to Actions. An Action consists mainly of a class implementing an interface;
ControllerAction. The Controller instantiates this class, and calls its
doAction() method. The
response objects are passed into this method, giving the Action access to everything that it needs.
So far, so good. But this is where is starts to get a little complex. What happens next?
We need to redirect (or forward) the client on to the View, usually a JSP, at this point. But we'll need to pass some information from the Action to the View. How do we do this? We are just returning a
ControllerActionResult object from our
ControllerAction.doAction() method, and stuffing this into our
session. This is working so far, but I'm worried.
Also, to which View should we redirect? Initially, we were just going to keep this in the
Controller's Action mapping, but of course, you might want to redirect to different JSPs depending on what the Action thinks. Do you just have a fixed number of potential target Views? Say, one for a successful Action, another for a used error, and another for an unexpected error? What if you need more options than this?
At the moment, our
ControllerAction.doAction() method is passing back the target View as an attribute of the
ControllerActionResult object, and we redirect according to this. This works OK, but will it scale?
Oh, BTW, we have decided that we will use JSTL's SQL taglib to present our financial data. To our application, it really is just a bunch of numbers, so building a Model is just unnecessary work. YAGNI. ;-)Posted to Java by Simon Brunning at February 10, 2004 04:45 PM