The Apache FAQ |
The Apache Software Foundation |
Apache Module Registry |
Apache Project |
The Jakarta Project |
Apache XML Project |
Apache-Perl Integration Project |
ApacheCon |
The Java Apache Project |
PHP Server Side Scripting |
Apache-Related Projects |
|
Linux Today |
All Linux Devices |
BSD Today |
Just Linux |
Linux Apps |
Enterprise Linux Today |
Apache Today
|
Linuxnewbie.org |
BSD Central |
Linux Programming |
PHPBuilder |
Linux Start |
Linux Planet |
Linux Central |
SITE DESCRIPTIONS |
|
|
Jaydoh's Template Mechanism - A Proven J2EE Pattern
Mar 26, 2001, 23 :50 UTC (0 Talkback[s]) (1423 reads) |
[ 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.
- No scripting is required in the templates (although, we do support JSP markup if you choose to code in the template). One and only one tag is introduced -- this tag has one attribute: name.
2. Don't change or interpret the content of a template.
- No assumptions are made regarding the content of your template, hence, once you understand Jaydoh's Template Mechanism, you can use it for any kind of text-based content. For example, you can use Jaydoh's Template Mechanism for WML(WAP).
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?
- To totally separate presentation from business logic.
- To easily combine a number of atomic components in a variety of ways.
- The template mechanism enables Rapid Prototyping. It allows the application interface to be completely built and have things become "dynamic" when they are ready.
- Its inheritance/region based implementation allows you to do things such as swap the look-and-feel depending on the device or user setting. For example, if the user is in a certain age range you can have a look-and-feel that targets that age-group.
- The template mechanism enables reuse of components: you can have the same Object Providers render content to different Templates -- that is, the same business object can be used when a browser connects to the service, in which case you stream back HTML, or when a WAP phone connects to the service, in which case you stream back WML.
- To enable a fast, iterative approach to application development. That is, Graphics Designers and Developers can work in parallel and integrate seamlessly and continuously.
- Let Graphics Designers work with the tools that they already understand and our productive with, such as Macromedia'sTM Dreamweaver. Jaydoh, even has a productivity aid that makes business objects look like library objects in Dreamweaver. Similarly, let Developers work with their favorite tools.
- It's debugger agnostic - meaning any standard debugger can debug all logic, line to line.
What type of content can be used?
- Any content type that is "text" based, such as: HTML, JSP, WML, XML/XSLT, VoxML, Java source, etc.
Other noteworthy features:
- The template mechanism supports nested templates.
- It supports Placeholder Substitution. Placeholders can be defined within a Template or within Page Provider (e.g. images) and can be substituted later via a lookup into a PropertiesMap. Jaydoh's PropertiesMap object supports the standard Java properties format as well as an XML based format. In addition, Jaydoh's PropertiesMap collection enables properties to reference other properties for their value and support cascading.
- Fully supports JSP markup.
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.
|
|