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.
Problem
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.
Context
System controls flow of execution and access to presentation processing, which is responsible for generating dynamic content.
Solution
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
FrontController
A FrontController can be used to initially handle the request, though its responsibilities are limited.
ApplicationController
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.
View
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.
BusinessHelper, ViewHelper
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.
PresentationModel
The PresentationModel holds the data retrieved from the business service, used to generate the View.
BusinessService
The BusinessService encapsulates the business logic and business state. A remote business service is accessed via a Business Delegate.
Example for Dispatcher View |
Greetings! This is my first visit to your blog!We are a team oof volunteers and starting a new initiative in a community in thhe same niche.Your bloog provided us useful information to work on. You ha