Your Daily Source for Apache News and Information  
Breaking News Preferences Contribute Triggers Link Us Search About
Jaydoh's Template Mechanism - A Proven J2EE Pattern
(Mar 26th, 23:50:09 )

[ Thanks to for this information. ]

In March 2001, Sun Microsystems released the first beta version of Sun Java Center J2EE Patterns. The J2EE patterns describe the typical problems encountered by enterprise application developers and document a pattern, or abstract solution, to these problems. The J2EE patterns are an important contribution to the industry because they provide developers with a common nomenclature and abstract solutions to recurring problems.

One recurring problem that all enterprise applications have in common is how to present data to the client. Do you use JSPs or Servlets? How do you effectively separate presentation from business logic? How can you support multiple devices without duplicating code? How do you avoid making multiple modifications to your application every time you make a change to your view layout?

J2EE Composite View

One design solution being put forth by Sun's J2EE patterns is the Composite View Pattern. "This solution provides for the creation of a composite view based on the inclusion and substitution of modular dynamic and static template fragments. This solution also promotes the reuse of atomic portions of the View, and encourages modular design. It is appropriate to use a composite view to generate displays containing pluggable atomic components that may be combined in a variety of ways. This scenario occurs, for example with portal sites that include numerous independent views, such as news feeds, weather information, and stock quotes on a single page. There may be a runtime overhead associated with this pattern, and it is the tradeoff for the pattern's improved flexibility.

A system typically has many views, some of which rely on similar atomic pieces of the display to be presented in alternate ways, such as in different locations on the screen or containing modified text. An example is a customer inventory table that is used on multiple pages, surrounded by different information on each page. Another example is a page that includes a header and footer. If each atomic subcomponent is coded directly into the main view in which it is included, the result is duplicate code that is difficult to modify and maintain.

When a component piece is coded directly into the view in which it is used, a change to that subcomponent requires changing each view that contains the subcomponent, requiring multiple modifications to make a single change."1

A Proven Implementation

Jaydoh's HTML Template Mechanism is a fully functioning implementation of the J2EE Composite View pattern and specifically targets the presentation problems detailed above.

Jaydoh's Template mechanism was created to promote the rapid development and easy maintenance of web based applications. The Template subsystem provides a modular mechanism that allows web applications to be built with a consistent look and feel with the capability of producing dynamic HTML content.

HTML templates also offer a clean separation between presentation and the business logic. By decoupling the details of the HTML from the backend JavaTM services, those stronger on web design can focus on the look and feel of the web site without having to learn Java or another programming language. Conversely, those strong in programming can focus on the development of the backend Java services and business logic without any knowledge or worry about how the results will be presented in HTML. In other words, multiple parties can now work in parallel to reduce development time. Changes are also easier to implement since a change in the business logic will not affect the presentation or look and feel of the application and vice versa.

Principals of Jaydoh's Template Mechanism:

1. Developer's develop and Graphic Designers design.


2. Don't change or interpret the content of a template.

How does it work?

Jaydoh's Template Mechanism, introduces a single tag that has one attribute, name. This tag has one purpose, to declare a name for an atomic region of content. You can declare as many regions as you desire, or none. Regions may also be nested.

Using these regions, you can create a final "rendered page" or View by combining a Template, with zero or more Page Providers (static fragments), and zero or more Object Providers (dynamic fragments) as shown in the diagram above.



Page Providers, can contain any number of nested regions and act like a template. For example, a typical Page Provider might be a company logo. Object Providers are actual Java objects that supply portions of content via method invocations -- that is, Object Providers generally provide information that is more dynamic (e.g. from business objects).

The interesting technical point is that, whether the content is static or dynamic, the Graphic Designers never need to know -- the only thing that Graphic Designers know about is regions, which is a very familiar concept.

The Template once again defines the regions it wants rendered by other components. If one of the configured Object Providers supplies an implementation, it is used. Otherwise, each configured Page Provider is asked if it can handle the region. If neither of these components can supply the defined region, then the Template's default implementation is used. If it helps, think of the relationship between these components as an inheritance hierarchy. Regions within Page Providers override regions defined in the Template, and regions defined within Object Providers override regions defined in Page Providers.

Why use it?

What type of content can be used?


Other noteworthy features:

Summary

The J2EE Composite View pattern identifies a recurring problem around an application's presentation layer and provides an abstract outline on how to solve the problem. Jaydoh's Template Mechanism is a fully functioning implementation of the Composite View pattern that provides a flexible and highly modular way of combining a series of static and dynamic components in a variety of ways.

For more information on Jaydoh and the Template Mechanism or on how you can get a free copy of Jaydoh, please visit www.servidium.com or contact .

For more information on Sun's J2EE Patterns, please see http://developer.java.sun.com/developer/technicalArticles/J2EE/patterns/

About Servidium

Servidium Inc. is a software company focused on the development of enterprise application development tools. Founded in August 1999, Servidium has developed a modular development platform, JaydohTM, which enables the rapid development of web and wireless applications through a collection of reusable and customizable components.

In addition, Servidium and its integration partners provide strategy and development solutions to clients that range from start-ups to Fortune 500 companies.

References:

1. http://developer.java.sun.com/developer/technicalArticles/J2EE/patterns/
Sun Java Center J2EE(TM) Patterns First Public Release: Version 1.0 Beta
From the Sun Java Center: by Deepak Alur, John Crupi, and Dan Malks - March, 2001.


Printed from Apache Today (https://apachetoday.com).
https://apachetoday.com/news_story.php3?ltsn=2001-03-26-001-06-NW-SW-DT

About Triggers Media Kit Security Triggers Login


All times are recorded in UTC.
Linux is a trademark of Linus Torvalds.
Powered by Linux 2.4, Apache 1.3, and PHP 4
Copyright INT Media Group, Incorporated All Rights Reserved.
Legal Notices,  Licensing, Reprints, & Permissions,  Privacy Policy.
http://www.internet.com/