Jump to content

Java view technologies and frameworks

From Wikipedia, the free encyclopedia

This is an old revision of this page, as edited by Jontyla (talk | contribs) at 02:42, 26 November 2011 (Added section about JSF/Facelets and added a few bits on JSF elsewhere). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

Various Java Web application frameworks have appeared in recent years. Some of them are in direct competition, while others are complementary technologies. It is therefore necessary to understand where exactly each technology/framework fits into the J2EE scheme of things. This page lists the View technologies. These are the frameworks which are used for defining the web pages and the server-side programs which handle the requests (clicks) generated by the web pages.

At a glance

HTTP Paradigm Component Paradigm Templating
Struts Wicket Tiles
Tapestry SiteMesh
JSF Facelets
Jt Design Patterns Click
  • Struts is relatively easier to use for beginners because it contains the familiar HTTP paradigm of Request/Response. However, the Component based frameworks are architecturally superior, and usually recommended for creating more complex web applications.
  • Wicket, Tapestry and JSF are competing technologies.
  • Tiles is a templating framework which is designed to work with Struts.
  • SiteMesh can be used with any JSP.
  • Facelets is a view definition and templating technology designed to work with JSF.
  • Jt is a design pattern framework for the rapid implementation of web applications. It features a wizard application for automated generation. It supports JSP, struts and Ajax.
  • Wicket, Tapestry and Facelets have their own native templating.
  • Click uses HTML based velocity templates and plain old Java objects. JSP is optional.

Servlet API

  • This is the foundation of almost all Java View technologies.
  • It provides the basic framework for writing Java classes, called 'Servlets' that can respond to HTTP Requests, create Cookies and maintain Sessions.

JSP

  • Built on top of the Servlet API, JSP provides for a HTML centric Server programming model.
  • Java code is embedded in the JSP files and is executed when a request is received.

Struts

  • Built on top of the Servlet API, Struts provides for decoupling between the Controller and the View.
  • Requests are received by a Java Class (Controller) which can decide which View to display.
  • The actual View is written as a JSP page.
  • An XML configuration file is used to specify the "Page Navigation", i.e. the flow of the request to the appropriate Controller, and which View to display based on the outcome of the Controller.
  • Competitor: Though Struts does not have any direct competitor in its league, Component View Technologies (like Wicket, Tapestry, JSF) are generally accepted as superior.

Tiles

  • This is a HTML templating framework based on the "Composite" model.
  • It allows for the HTML page to be broken up into multiple pagelets, called Templates, Definitions and Composing pages.
  • At run time the pagelets are stitched together to generate the final HTML. Pages are written in JSP.
  • Competitor: SiteMesh

SiteMesh

  • SiteMesh is a HTML templating framework based on the "Decoration" model.
  • It allows for the creation of a 'decoration' template which is then applied to any other HTML to generate a new HTML.
  • The newly generated HTML contains elements from the original HTML blended into the template.
  • This allows for the original HTML to be very simple and devoid of any formatting or layout specification. The template, in turn, is devoid of any actual information.
  • Blending the two allows for a consistent look and feel for all web pages.
  • Competitor: Tiles...

Wicket

  • Wicket provides a 'Component' view technology - meaning the Request-Response Stateless paradigm of HTTP is abstracted away to give rise to an Object Oriented Stateful paradigm.
  • Pages now directly interact with Stateful Java Components on the server.
  • Components and their State are managed by the Wicket framework, freeing the application developer from having to use HttpSession directly to manage state themselves.
  • Further, Wicket provides for a clear separation of HTML markup from code, and there are no XML configuration files to manage.
  • Web page components are 'pushed' into the HTML markup from the code.
  • Competitor: Tapestry, JSF

Tapestry

  • Tapestry provides a 'Component' view technology.
  • Classes are written as POJOs and Annotations are used to configure them as Tapestry components.
  • HTML components can directly refer to the component methods and attributes.
  • Competitor: Wicket, JSF

JSF/Facelets

  • Java Server Faces provides a 'Component' view technology while Facelets (optionally) provides xml/xhtml based view definition and templating.
  • Classes are written as POJOs and Annotations or configuration files are used to associate them with Faces.
  • The Unified Expression Language allows binding component fields and events to POJO bean properties and methods.
  • Conversion and validation constraints can be specified in Facelets and are automatically applied, normally resulting in reposting of the same page with error information in case of failure.
  • Navigation can be via configuration file rules or directly specified in the page.
  • Can transparently support Ajax.
  • Competitor: Wicket, Tapestry

References