©


Core J2EE Pattern Catalog

© CoreJ2EEPatterns
All Rights Reserved.

Last Updated:
January 29, 2006 8:54 PM

 

In Association with Amazon.com


View Helper

See Core J2EE Patterns, 2nd Edition for full description of this pattern and its strategies.

Problem

You want to separate a view from its processing logic.

Forces

  • You want to use template-based views, such as JSP.
  • You want to avoid embedding program logic in the view.
  • You want to separate programming logic from the view to facilitate division of labor between software developers and web page designers.

Solution

Use Views to encapsulate formatting code and Helpers to encapsulate view-processing logic. A View delegates its processing responsibilities to its helper classes, implemented as POJOs, custom tags, or tag files. Helpers serve as adapters between the view and the model, and perform processing related to formatting logic, such as generating an HTML table.

Class Diagram

Sequence Diagram

Strategies

  • Template-Based View Strategy
  • Controller-Based View Strategy
  • JavaBean Helper Strategy
  • Custom Tag Helper Strategy
  • Tag File Helper Strategy
  • Business Delegate as Helper Strategy

Consequences

  • Improves application partitioning, reuse, and maintainability
  • Improves role separation
  • Eases testing
  • Helper usage mirrors scriptlets

Related Patterns

  • Front Controller
    A Front Controller typically delegates to an Application Controller , to perform action and view management.
  • Application Controller
    An Application Controller manages view preparation and view creation, delegating to views and helpers.
  • View Transform
    An alternative approach to view creation is to perform a View Transform.
  • Business Delegate
    A Business Delegate reduces the coupling between a helper object and a remote business service, upon which the helper object can invoke.
Contact Us © CoreJ2EEPatterns.com. All Rights Reserved. Terms of use