Learn Java for Web Development

(Tina Meador) #1

152 CHAPTER 3: Best Practices in Java EE Web Development


Composite View

In web applications, views are often built by embedding formatting code directly within each view.
This makes modifying the layout of multiple views difficult. The Composite View pattern allows a
parent view to be composed of subviews. Hence, the overall view becomes a composition of smaller
subviews that are included dynamically in the overall view.


The components of the Composite View pattern are as follows:


   Basic view: This is the basic abstraction of the view.
 Composite view: This is a view that is composed of a number of subviews.
 The view: This is a simple view that has no subviews.

Figure 3-13 shows the basic structure for the Composite View pattern.


View View Helper

Figure 3-12. View Helper class diagram


View

Simple View CompositeView

Figure 3-13. Composite View class diagram


Figure 3-14 illustrates the usage of the Composite View pattern.


Figure 3-12 illustrates the structure of the View Helper pattern.

Free download pdf