Kontakt

Tapestry 5.3 Preview

Posted on Montag, 22nd August, 2011

The Tapestry team has been very busy in the last months and it looks like Tapestry 5.3 goes Beta. While we are working on fixing last minor issues before version 5.3 becomes generally available, I want to share with you some of the new upcoming features.

From the user perspective Tapestry 5.3 will be the most attractive release since 5.0. This article gives you a short overview.

New Components

Several components has been added to the core library:

  • Kaptcha / KaptchaField: Allow you to protect your forms from spam.
  • Tree: Used to render a recursive tree structure, with expandable/collapsable/selectable nodes.
  • Dynamic: An awesome component¬†allowing a component to render itself differently at different times, by making use of an external template file. More details on this component follow in the next post
  • Checklist:¬†Multiple selection component. Generates a UI consisting of a list of check¬†boxes. This component is used as alternative to the Palette component.
  • Alerts: Used to display alerts.

Alerts

In the past the only way to present some messages to the user was to persist some page properties using the flash strategy.¬†Now Tapestry provides a central mechanism for handling user alerts: the AlertManager service and the Alerts component. Using AlertManager service you can add alerts which are presented to the user using the Alerts component. Alerts can be added during both traditional and Ajax requests, and may be transient (displayed for a few seconds), normal, or sticky (persist until the user expressly dismisses them). Alerts support three severities: info, warn(ing) and error; the look and feel can be customized by overriding Tapestry’s default CSS rules.

Template Skinning

I discussed template skinning feature in this article.

Improved Exception Reporting

Tapestry is known to provide excellent messages when something goes wrong. In version 5.3, the exception reporting has been improved for Ajax requests. Please watch this screencast for more details.

New JavaScript Abstraction Layer

As you probably know, Tapestry is stuck with using¬†Prototype and Scriptaculous for backward compatibility reasons. A lot of Tapestry users has been complaining about missing support of jQuery. Those of you, how can’t live without jQuery are probably using this Tapestry/jQuery library which allows you to get rid of Prototype and Scriptaculous.

Breaking backward compatibility with existing apps just by rewriting the client-side code to jQuery is not an option. Also¬†tying Tapestry to jQuery wouldn’t be a good decision. If yet another JavaScript library will become successful next year and everybody starts to migrate, you are stuck again. A much better solution is to provide an abstraction layer which allows you to use any JavaScript library you like just by replacing a couple of files. Some work has already been done in Tapestry 5.3. The transition is done¬†gradually and will be finalized in version 5.4.

Improved Ajax

The MultiZoneUpdate class has been deprecated in favor of AjaxResponseRenderer service. This service manages the rendering of a partial page render as part of an Ajax response. Let’s see a simple example.

public class AjaxDemo {
    @Inject
    private Block block;

    @Inject
    private AjaxResponseRenderer ajaxResponseRenderer;

    @Inject
    @Path("MultiZoneUpdateDemo.js")
    private Asset library;

    void onActionFromUpdate() {
        ajaxResponseRenderer.addRender("zone", block);

        ajaxResponseRenderer.addCallback(
                    new JavaScriptCallback() {
            public void run(JavaScriptSupport support) {

                support.importJavaScriptLibrary(library);
                support.addInitializerCall(
                     "writeMessageTo",
                     new JSONObject("id", "message",
                                    "message", "Updated"));
         }
        });
    }
}

As you can see, the new API allows us to update a zone with the content from a renderer (such as a Block, Component or other object that can be coerced to RenderCommand). It is also possible to queue a JavaScriptCallback to be executed during the partial markup render. In this example the callback is used to import a JavaScript library as part of the rendered page and to add a call to a client-side function inside the Tapestry.Initializer namespace.

JSR 330 Integration

Starting from Tapestry 5.3, it’s possible to use JSR-330 annotations for injection. Using the standard annotations, your code in the service layer doesn’t need to depend on Tapestry. Please read this article for more details.

JPA 2 Integration

Finally, Tapestry provides a native JPA 2 integration. How does it differ from¬†Tynamo’s JPA integration? First of all, it is maintained by the Tapestry team, that will ensure the backward compatibility with future releases. Secondly, it provides some features that were not available in Tynamo. For example, you can have multiple persistence units in the same application. Furthermore, Tapestry allows you to configure JPA without XML. Read this article for more details.

JavaScript and CSS Compression

A module integrating Yahoo’s¬†YUI Compressor has been added. This library allows you to compress your JavaScript and CSS.

Component Reference

Great news for component developers. Starting with Tapestry 5.3 generating a component reference will be as easy as writing JavaDoc. You no longer need to use Maven. Instead you just need to place @tapestrydoc in the component’s class JavaDoc. That’s all. The following screenshot¬†demonstrates the result.

Scheduling Jobs

The PeriodicExecutor service has been introduced to allow execution of scheduled jobs. The following example demonstrates how to schedule a job to be executed every 5 minutes.

public class PeriodicExecutorDemo {

    public PeriodicExecutorDemo(PeriodicExecutor executor) {

       executor.addJob(
          new IntervalSchedule(300000L),
          "MyJob",
           new Runnable () { void run() { ... }; } );
    }
}

 

Plastic

Plastic is a bytecode transformation library based on ASM. Plastic is designed to simplify the run-time transformation of Java classes. The most parts of the internal API using Javassist has been rewritten to use Plastic. The Javassist-based API has been deprecated and will be removed in Tapestry 5.4. Starting from version 5.4 Tapestry will not longer depend on Javassist. Yay!

 

Have fun with Tapestry and stay tuned!

 

  1. Sigbj√łr

Tapestry 5 Blog - Copyright © 2009 - Eclectic Theme by Your Inspiration Web - Powered by WordPress