Learn Java for Web Development

(Tina Meador) #1
CHAPTER 3: Best Practices in Java EE Web Development 151

View Helper

In a web application, the presentation content (that is, the content of the JSP page) requires the
processing of dynamic content. Presentation tier changes occur often and are difficult to develop
and maintain when the business logic and presentation logic are intermingled. In fact, intermingling
the business logic and presentation logic makes the presentation unmaintainable. The View Helper
design pattern decouples the presentation tier from with the business tier and generates views
based on a template. The components in the View Helper pattern are as follows:


   View
 View helper

View

A view contains the presentation formatting logic and delegates the business processing logic in the
presentation to the helper.


View Helper

The view helper does the following:


   A view helper can be implemented as a JavaBean implementation or a custom
tag implementation. We used this pattern in Chapter 2.
 Helpers serve as the view’s intermediate data model.
 Helpers are responsible for getting data from a business service.
 Presentation business logic is encapsulated in the helper.

Client Front Controller

Request
Delegate

Dispatch

Dispatcher View

Figure 3-11. Front controller sequence diagram

Free download pdf