This chapter gives detailed description of few advanced features of Apache Tapestry.
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
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
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.
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.
Live class reloading can be disabled by setting production mode to true in AppModule.java.
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 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 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.
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
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.
Apache Tapestry Tutorial
All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.