Optimize with a SATA RAID Storage Solution
Range of capacities as low as $1250 per TB. Ideal if you currently rely on servers/disks/JBODs
The View Helper pattern specifies that you use helpers to adapt model data to the presentation layer of an application. Typically, the presentation layer contains several JSP (JavaServer Pages) pages. These pages consist of HTML and images used to present content to the user. A problem arises, however, when these pages need to display dynamic content stored in the model. You'd probably like to avoid embedding Java code within these pages to display model data, so you need to employ some helpers to do the work for you.
Recall from the previous chapter that the controller servlet attaches the model to the request as an attribute. To get at this model from within the JSP page, you have three choices. You could embed Java code as JSP scriptlets, you could use the EL, or you could use a helper to extract the data for you. In keeping with the idea of separating presentation from business logic, it makes sense to employ several helpers to adapt the model to the presentation rather than clutter the presentation code with Java code (see Figure 1).

Figure 1. View Helper pattern
As you can imagine, helpers make it a lot easier for page designers to develop the presentation layer by replacing Java code with simple-to-use helpers. Of course, developers can accomplish this only if they publish a catalog of the helpers and describe how to use them. However, if the page designers develop their pages before the application designer is ready to give them a model for the helpers with which to work, then there's a problem. A useful technique to address this problem is to code into the helper a set of dummy data to display when no model is present. An alternate approach would be to provide a dummy model with which to work. Either way, the page designer shouldn't be held up while waiting for the developers.
Using helpers has the following advantages:
When developing helpers for JSP pages, you have two choices. You could use either JavaBeans or custom tags. Which you choose really depends on the type of data you're trying to adapt. Typically, you use JavaBeans to extract individual pieces of data, and custom tags are better suited for working with sets of data. However, it's important to point out that you can use either for both types of data.
You can implement helpers as JavaBeans within a JSP page. These helpers are typically easy to use when extracting and formatting single text items. The built-in JSP tags that enable you to work with JavaBeans are simple and intuitive to use. Using JavaBeans involves simply declaring the bean and referencing it later using the special tags as follows:
Archived Discussions (Read only)