Avijeet Dash and Satyabrata
Dash
The problems solved by Front Controller and View Helper patterns in
presentation layers is to provide centralized components for managing access
control, content retrieval, view management. These patterns also provide a clear
separation of role among the different layers.
Service to worker and Dispatcher View are patterns, which are combination of
Front Controller and view Helper patterns with a dispatcher component. Though
the structure of the two patterns is more or less same, they are different in
usage of the patterns.
The basic difference lies in the fact that Service to worker promotes more
"up front" work by the controller and dispatcher for authentication,
authorization, content retrieval, validation, view management and navigation. On
the other hand Dispatcher View have relatively lightweight controller and
dispatcher with minimal functionality and most of the functionality is done by
the view it self.
The controller and dispatcher typically play a moderate to large role in
Service to worker. And in Dispatcher View controller and dispatcher play a
limited to moderate role.
The functionality of view management, which is to decide which view to choose
next can be simplified by passing in the next-view information in the request
itself. For an example, click
http://some.server.com/servlet/Controller?next=login.jsp
or
http://some.server.com/servlet/Controller?action=login
In such cases the dispatcher functionality is fairly minimal of simply
forwarding the request and response to the next view using RequestDispatcher.
Dispatcher may use a XML file to map the action element to a JSP file. The
container itself mostly provides this functionality. Dispatcher view may use
such a simple dispatcher as a function in controller or a separate component.
The dispatcher in the service to worker is more sophisticated and may use
business service to decide the next view.
The controller in Service To worker has all the responsibilities of system
services as well as using the helper for talking to business service to get the
display content.
The controller in Dispatcher View may have minimal services of system
services but doesn’t do any content retrieval, which is done by the view
itself. If the system services are minimal, the controller and dispatcher
components can be completely removed and the request can be directly go to the
view.
See the sequence diagrams to see how the components interact in the two
patterns.
Click to view
Service to worker
sequence diagram
Dispatcher view sequence diagram
Sample Code
View in Service to Worker
The AccountVO is the Value Object or Bean Value, which is created by the
command by using a helper. The value object is set to the request object, which
is used by the view for display.
    class="corepatterns.util.AccountVO"
/>
Account Detail for
   name="account"
property="owner" />
   name="account"
property="owner" />
Account Number : |
View in Dispatcher view
Here the view uses a jsp tag to extract the value object.
Example 7.35 View à accountdetails.jsp
<%@ taglib uri="/web-INF/corepatternstaglibrary.tld"
   prefix="corepatterns"
%>
   queryParams="custid,acctkey"
scope="request" />
Account Detail for
   attribute="owner"
/>
   attribute="owner"
/>
  Â
Number :
  Â
  Â
  Â
Type:
  Â
  Â