Apache Tapestry Explained

Apache Tapestry
Author:Howard Lewis Ship
Developer:Apache Software Foundation
Operating System:Cross-platform (Java Virtual Machine)
Programming Language:Java
Genre:Web application framework
License:Apache License 2.0

Apache Tapestry is an open-source component-oriented Java web application framework conceptually similar to JavaServer Faces and Apache Wicket.[1] Tapestry was created by Howard Lewis Ship, and was adopted by the Apache Software Foundation as a top-level project in 2006.[2]

Tapestry emphasizes simplicity, ease of use, and developer productivity. It adheres to the Convention over Configuration paradigm, eliminating almost all XML configuration.[3] Tapestry uses a modular approach to web development by having a strong binding between each user interface component (object) on the web page and its corresponding Java class. This component-based architecture borrows many ideas from WebObjects.[4]

Notable features

Live Class Reloading: Tapestry monitors the file system for changes to Java page classes, component classes, service implementation classes, HTML templates and component property files, and it hot-swaps the changes into the running application without requiring a restart. This provides a very short code-save-view feedback cycle that is claimed to greatly improve developer productivity.[5]
  • Component-based : Pages may be constructed with small nestable components, each having a template and a component class. Custom components are purportedly trivial to construct.[6]
  • Convention over configuration: Tapestry uses naming conventions and annotations, rather than XML, to configure the application.[7]
  • Spare use of HTTPSession : By making minimal use of the HTTPSession, Tapestry is designed to be highly efficient in a clustered, session-replicated environment.[8]
  • Post/Redirect/Get: Most form submissions follow the Post/Redirect/Get (PRG) pattern, which reduces multiple form submission accidents and makes URLs friendlier and more bookmarkable, along with enabling the browser Back and Refresh buttons to operate normally.[9]
  • Inversion of Control (IoC): Tapestry is built on a lightweight Inversion of Control layer with similarities to Google Guice, but designed to make nearly all aspects of Tapestry's behavior configurable and replaceable.[7]
  • Hello World Example

    A minimal, templated Tapestry application needs only three files:

    HelloWorld.tml
  • The (X)HTML template for the /helloworld page. Tapestry templates can contain any well-formed (X)HTML markup.

    Hello, $

    HelloWorld.java
  • The page class associated with the template. Here, it merely provides a *username* property that the template can access.package org.example.demo.pages;

    /** A page class (automatically associated with the template file of the same name) */public class HelloWorld

    web.xml
  • The servlet application Deployment Descriptor, which installs Tapestry as a servlet filter. Tapestry Example tapestry.app-package org.example.demo app org.apache.tapestry5.TapestryFilter app /*

    Class transformation

    Tapestry uses bytecode manipulation to transform page and component classes at runtime. This approach allows the page and component classes to be written as simple POJOs, with a few naming conventions and annotations potentially triggering substantial additional behavior at class load time. Tapestry versions 5.0, 5.1 and 5.2 used the Javassist bytecode manipulation library. Subsequent versions replaced Javassist with a new bytecode manipulation layer called Plastic that is based on ObjectWeb ASM.[10] [11]

    Client-side support

    Tapestry 5 versions up through 5.3 bundled the Prototype and script.aculo.us JavaScript frameworks, along with a Tapestry-specific library, so as to support Ajax operations as first-class citizens. Third party modules are available to integrate jQuery instead of, or in addition to, Prototype/Scriptaculous.

    Starting with version 5.4, Tapestry includes a new JavaScript layer that removes built-in components' reliance on Prototype, allowing jQuery or another JavaScript framework to be plugged in.[12]

    Version 5.4 also introduces support for JavaScript modules using the RequireJS module loading system.

    Core principles

    The Tapestry project documentation cites four "principles" that govern all development decisions for Tapestry, starting with version 5 in 2008:[13]

    Criticism

    Tapestry has been criticized as not being backward-compatible across major versions, especially noted in the transition from version 4 to version 5, where no clean migration path was available for existing applications.[14] Project team members have acknowledged this as a major problem for Tapestry's users in the past, and backward compatibility was made a major design goal for Tapestry going forward. From early on in the development of version 5, backward compatibility was listed as one of Tapestry's four new "Core Principles", and two of the other three were intended to make the evolution of the framework possible without sacrificing backward compatibility. Project team members claim that all Tapestry releases since 5.0 have been highly backward compatible.

    Early criticisms of Tapestry 5 also mentioned documentation as a shortcoming. Project members now claim that this deficiency has been largely addressed with a thoroughly revised and updated User's Guide and other documentation.

    Since version 5.0, Tapestry has bundled the Prototype and Scriptaculous JavaScript libraries. According to Howard Lewis Ship, in the 2008-2009 timeframe these were reasonable choices. Since then, however, Prototype's popularity has declined, and jQuery's has risen dramatically. In response, the Tapestry community developed modules that allowed jQuery to be used in addition to, or instead of, Prototype. Meanwhile, the current version of Tapestry, 5.4, removes the dependency on Prototype entirely, replacing it with a compatibility layer into which either jQuery or Prototype (or potentially any other JavaScript framework) can be plugged.

    Relation to other frameworks

    According to Howard Lewis Ship, Tapestry was initially conceived as an attempt to implement in Java some of the general concepts and approaches found in WebObjects, which was at that time written in Objective-C and closed-source.[15]

    Apache Wicket was developed as a response to the complexity of early versions of Tapestry, according to Wicket originator Jonathan Locke.[16]

    Facelets, the default view technology in JavaServer Faces, was reportedly inspired by early versions of Tapestry, as an attempt to fill the need for "a framework like Tapestry, backed by JavaServer Faces as the industry standard".[17] [18]

    History

    Version Date Description
    2000 Developed by Howard Lewis Ship for internal use
    2002-04 First made available on SourceForge under the GNU Lesser General Public License.[19]
    2004-04 The first release under Apache, as a Jakarta sub-project.[20]
    2006-01 Introduced support for JDK 1.5 annotations, a new input validation subsystem, and improved error reporting [21]
    2008-12 A nearly complete rewrite from Tapestry 4, introducing a new POJO-based component model emphasizing convention over configuration, and replaced Hivemind with a new no-XML Inversion of Control layer.
    2009-04 Performance and memory improvements, automatic GZIP compression, JavaScript aggregation, but remained backwards compatible to Tapestry 5.0.
    2010-12 Added JSR 303 Bean Validation.[22] Extended live class reloading to service implementations. Removed page pooling.[23]
    2011-11 Added support for HTML5 doctype, JSR-330 annotations for injection,[24] performance and memory improvements, new components, switched from JavaAssist to ASM bytecode manipulation
    2012-2014 Bug fixes and minor enhancements
    2015-2019 Major client-side enhancements. New JavaScript layer for switchable jQuery/Prototype support, uses Require.js for its JavaScript module system, Twitter Bootstrap for its default styling.[25]
    2020-03 Current stable version. Support for Java 12 bytecode, Typescript, and Bootstrap 4.

    See also

    References

    Notes

    Notes and References

    1. Web site: Howard Lewis Ship of Tapestry interview [part 1] (2012-10-22)]. 2013-01-28. https://web.archive.org/web/20130122114626/http://devrates.com/post/show/345948/howard-lewis-ship-of-tapestry-interview-%5Bpart-1%5D. 2013-01-22. dead.
    2. Drobiazko 2012, p. 1.
    3. Web site: Tapestry Central: Tapestry 5 Updates. 24 July 2006 .
    4. Tapestry in Action - Preface by Howard Lewis Ship
    5. Web site: Class Reloading - Apache Tapestry.
    6. Drobiazko 2012, p. 20.
    7. Drobiazko 2012, p. 7.
    8. Web site: Performance and Clustering - Apache Tapestry.
    9. Web site: Forms and Validation - Apache Tapestry.
    10. Web site: Meeting Plastic I: Introduction Java Magic. 18 April 2011 .
    11. Web site: [asm] Plastic: An ASM wrapper for Tapestry 5.3 . 2013-02-21 . https://web.archive.org/web/20130618005639/http://mail-archive.ow2.org/asm/2011-04/msg00033.html . 2013-06-18 . dead .
    12. Web site: Tapestry Central: Zeroing in on Tapestry 5.4. 19 October 2012 .
    13. Web site: Principles . 2012-10-12 . 2010-12-21 . https://web.archive.org/web/20121012021755/http://tapestry.apache.org/principles.html. 12 October 2012 . live.
    14. Web site: Tapestry5 future . 2013-01-21 . 2009-04-30 . 2013-01-21 . https://web.archive.org/web/20130121232236/http://tapestry.1045711.n5.nabble.com/Tapestry5-future-compatiblity-td2431085.html . dead .
    15. Web site: DevRates | Howard Lewis Ship of Tapestry interview [part 1] . 2013-01-28 . https://web.archive.org/web/20130122114626/http://devrates.com/post/show/345948/howard-lewis-ship-of-tapestry-interview-%5Bpart-1%5D . 2013-01-22 . dead .
    16. Web site: Wicket: Do we need yet another presentation layer framework? . www.theserverside.com . 11 January 2022 . https://web.archive.org/web/20040909074534/http://www.theserverside.com/news/thread.tss?thread_id=28162 . 9 September 2004 . dead.
    17. Web site: Facelets: JavaServer Facelets . facelets.dev.java.net . 11 January 2022 . https://web.archive.org/web/20070706220453/https://facelets.dev.java.net/ . 6 July 2007 . dead.
    18. Web site: JSF Central - Inside Facelets Part 1: An Introduction . www.jsfcentral.com . 11 January 2022 . https://web.archive.org/web/20130113100928/http://www.jsfcentral.com/articles/facelets_1.html . 13 January 2013 . dead.
    19. Web site: Tapestry: Java Web Components Release 2.0 is Out. 2013-01-20 .
    20. Web site: Tapestry 3.0 Final Release. 2013-01-20 .
    21. Web site: Tapestry 4.0 Released. 2013-01-20 .
    22. Web site: Tapestry and JSR-303 Bean Validation API . 2010-03-13 . 2010-01-04 . https://web.archive.org/web/20100416154003/http://blog.tapestry5.de/index.php/2010/01/04/tapestry-and-jsr-303-bean-validation-api/. 16 April 2010 . live.
    23. Web site: Announcing Tapestry 5.2 . 2012-11-14 . 2010-12-17 . https://web.archive.org/web/20121114182121/http://tapestry.apache.org/2010/12/17/announcing-tapestry-52.html/. 14 November 2012 . live.
    24. Web site: Using JSR 330 standard annotations - Apache Tapestry.
    25. Web site: JavaScript Rewrite. 2013-01-20 . https://web.archive.org/web/20121114180615/http://tapestry.apache.org/javascript-rewrite.html. 2012-11-14.