Apache Tapestry Advanced Features - Apache Tapestry

What are the advanced features on Apache Tapestry?

This chapter gives detailed description of few advanced features of Apache Tapestry.

Inversion of Control

Tapestry uses IoC for all its features and offers built-in Inversion of Control library and is intensely integrated into IoC. Tapestry IoC configuration is based on Java and its IoC based modules are packaged into JAR file and dropped into classpath with zero configuration. Its usage is based on precision, which means

  • Small interfaces of 2 or 3 methods.
  • Small methods with 2 or 3 parameters.
  • Unknown communication via events, rather than explicit method invocations.


Modules are a way for extending the functionality of the Tapestry application. Tapestry has both inbuilt modules and huge number of third-party modules. Hibernate is one of the popular module provided by Tapestry and it also has modules integrating JMX, JPA, Spring Framework, JSR 303 Bean Validation, JSON, etc. Some of the important third-party modules are

  • Tapestry-Cayenne
  • Tapestry5-googleanalytics
  • Gang of tapestry 5 - Tapestry5-HighCharts
  • Gang of tapestry 5 - Tapestry5-jqPlot
  • Gang of tapestry 5 - Tapestry5-Jquery
  • Gang of tapestry 5 - Tapestry5-Jquery-mobile
  • Gang of tapestry 5 - Tapestry5-Portlet

Runtime Exceptions

Detailed Error Reporting is one of the best features of tapestry and it helps a developer by providing state of art exception reporting. Tapestry exception report is a simple HTML which contains detailed information so that it is easy to understand the report. Tapestry shows the error in HTML as well as stores the exception in a plain text along with date and time of the exception occurred, this will help the developer in checking the exception in production environment. Developer can easily fix any issues like broken templates, unexpected null values, unmatched request, etc.

Live Class and Template Reloading

Tapestry reloads the templates and classes automatically when they are modified. This feature helps in immediate reflection of application changes without going through build and test cycle and it also significantly improves application development productivity.

Consider root package of the application is org.example.myfirstapp, then classes in below paths are scanned for reloading.

  • org.example.myfirstapp.pages
  • org.example.myfirstapp.components
  • org.example.myfirstapp.mixins
  • org.example.myfirstapp.base
  • org.example.myfirstapp.services

Live class reloading can be disabled by setting production mode to true in AppModule.java.

Unit Testing

Unit testing is a technique where different pages and components are tested individually and Tapestry provides easy options for unit testing the pages and components.

Unit testing a page: Tapestry provides a class called PageTester for testing the application and this class acts as both browser and servlet container. It renders a page without browser in the server-side itself and the resulting document can be checked for correct rendering. Consider a simple page Hello, which renders hello and the hello text is enclosed inside an html element with id hello_id. For testing this feature, PageTester as shown below can be used

PageTester, in addition to rendering the page, provides an option for including context information, form submission, link navigation etc.

Integrated Testing

Integrated testing is testing the application by integrating multiple modules as a unit. Tapestry provides a small library called Tapestry Test Utilities for integrated testing and this library integrates with Selenium testing tool to perform testing. Library provides a base class called SeleniumTestCase, which starts and manages the Selenium server, Selenium client and Jetty Instance.

Below is an example for integrated testing

Development Dashboard

Development dashboard is the default page used for identifying and resolving the problems in the application. Dashboard can be accessed by the URL http://localhost:8080/myfirstapp/core/t5dashboard and it shows all the pages, services and component libraries that are available in the application.

Response Compression

Tapestry automatically compresses the response using GZIP compression and streams it to the client. This feature reduces network traffic and helps in faster delivery of the page. Compression can be configured using the symbol tapestry.min-gzip-size in AppModule.java and the default value is 100 bytes. Tapestry compresses the response when size of the response exceeds 100 bytes.


Tapestry provides many options for securing the application from known security vulnerabilities in the web application. Few of them are listed below

  • HTTPS − Tapestry pages can be annotated with @Secure to make it a secure page so that they are accessible only by https protocol.
  • Page access control − Controls the page access by specific users only.
  • White-Listed Page − Tapestry pages can be annotated with a @WhitelistAccessOnly for making it accessible only through localhost.
  • Asset Security − only certain types of files are accessible In tapestry and others can be accessed only when MD5 hash of the file is provided.
  • Serialized Object Date − Tapestry integrates a HMAC into serialized Java object data and sends it to the client to avoid message tampering.
  • Cross Site Request Forgery − Tapestry provides a 3rd party module called tapestry-csrf-protection to prevent any CSRF attacks.
  • Security Framework integration − Tapestry does not lock into a single authentication / authorization implementation, but can be integrated with any popular authentication framework.


Tapestry provides extensive support for logging, automatic recording on the application progress as it runs. Tapestry uses the de-facto Java logging library, SLF4J. The annotation @Log can be in any component method to avoid the entry and exit of the method and the possible exception as well. Also, the Tapestry provides logger object which can be injected into any component using the @Inject annotation as shown below

Finally, Apache Tapestry provides best ways for building concise, scalable, maintainable, robust and Ajax-enabled applications and can be integrated with any third-party Java application. It also helps in creating a big web application as it is very easy and fast.

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

Apache Tapestry Topics