Chapter 7. Application and system design guidelines 151
򐂰 Complete separation of the View-specific logic from the business logic, for
example, currency conversion based on the user preference.
򐂰 Using inheritance can promote view bean reuse and ensure that similar
information is received by all users, for example, CSRs and customers.
򐂰 View beans can be used with tools such as Rational Developer or IBM
WebSphere Studio Application Developer, which allows a developer to insert
JavaBean properties into JSPs.
򐂰 JSPs and associated view beans can be exhaustively unit tested by the View
developer prior to integration with the rest of the application.
On the other side, it is important to recognize the following disadvantages of
introducing result beans and view beans:
򐂰 View beans are tightly coupled with display pages and interaction controllers.
This implies that any changes to the dynamic content of the display page will
require a change to the interaction controller. We depend on the interaction
controller to gather all the required information in one view bean.
򐂰 For small applications, the introduction of view beans could result in too many
individual pieces of code and could increase the complexity of application
management.
򐂰 The number of artifacts to be coded, managed, and maintained will be
increased.
7.2.4 Formatter beans design pattern
The view bean concept described in the previous section tries to minimize the
need for inserting Java code directly inside a display page. In order to insert
complex tables or drop-down lists, complex conditional loops may be needed.
JSP API 1.1 does not define repeat tags that allow for looping through an
indexed JavaBean property. One option to overcome this is to implement the
complex table or drop-down list generation in Java and wrap it inside a bean.
Such reusable beans are called
formatter beans.
To summarize, a formatter bean is a bean that wrappers reusable HTML
formatting logic inside a method.
Advantages and disadvantages of formatter beans
Some advantages of formatter beans are:
򐂰 Eliminates the need for inserting complex scripting logic inside a JSP.
򐂰 Promotes reusability of the formatting logic.
򐂰 Hides the complexity of scripting logic from view designers.

Get Patterns: Implementing Self-Service in an SOA Environment now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.