J2EE Design Pattern : Presentation Tier Patterns : Dispatcher View Design Pattern
|Dispatcher View Design Pattern?|
Dispatcher View combines a dispatcher component with the Front Controller and View Helper Patterns, deferring many activities to View processing.
The problem is a combination of the problems solved by the Front Controller and View Helper patterns in the presentation tier. There is no centralized component for managing access control, content retrieval or view management, and there is duplicate control code scattered throughout various views. Additionally, business logic and presentation formatting logic are intermingled within these views, making the system less flexible, less reusable, and generally less resilient to change.
System controls flow of execution and access to presentation processing, which is responsible for generating dynamic content.
Use Dispatcher View with views as the initial access point for a request. Business processing in limited form is managed by the views. Use this approach when response generation requires little or no dynamic content, through a business service or data access call.
- The response is entirely static that is, a static HTML page.
- The response is dynamic generated from the presentation model.
Use “Service to Worker” if there is a large dynamic component to the response and the presentation model must be retrieved via business service invocations.
Non-software Dispatcher View Example
Dispatcher View Class Diagram
Participants and Responsibilities
A FrontController can be used to initially handle the request, though its responsibilities are limited.
An ApplicationController can be used to perform limited view management, but no action management. The application controller roles and responsibilities may be fulfilled directly by the container.
A View represents and displays information to the client. The PresentationModel is adapted for display by View Helpers. The view can be a Composite View.
A helper is responsible for helping a view or controller perform specific processing. A BusinessHelper helps a controller initiate business processing to handle a request, while a ViewHelper retrieves and adapts aspects of a PresentationModel to help generate a View.
The PresentationModel holds the data retrieved from the business service, used to generate the View.
The BusinessService encapsulates the business logic and business state. A remote business service is accessed via a Business Delegate.
|Example for Dispatcher View|