Strictly Programming

New features in Tapestry 5.0.11

Posted in Tapestry 5 by sqllyw on 03/15/2008

Some new features found in the Tapestry’s latest release.

1. The @Cached annotation has been added to allow the caching of method results.

public List getListOfDataType() {
return someExpensiveMethodCall();


<t:if test="listOfDataType.size()">
 <t:loop source="listOfDataType">
 <t:parameter name="else">
    No data to display

W/out @Cached, the above template results in some expensive method call being called 2x per render. Would be nice to call it only once/render.So if you change .java to look like:

public List getListOfDataType() {
   return someExpensiveMethodCall();

Now some Expensive MethodCall() will only occur once/render.

2. Tapestry can now generate accessor methods for fields automatically via the @Property annotation.

Traditionally you write code this way:

private String myName;

public String getMyName() { return myName;}
public void setMyName(String myName) { this.myName = myName}

Now the getter/setter method will be generated during run time:

private String myName;

However if you need to set the value from other classes, then the traditional way is needed. This applies to only classes controlled by tapestry. That is, components, mixins, pages and base-classes, that excludes entity classes

3. It is now possible to override the built-in display and edit blocks for data types.

Tapestry supplies a set of “defaults” for editing & viewing data types via BeanEditor, BeanEditForm, Grid, BeanDisplay, and so forth. Now you can override the defaults. As an example, due to licensing issues, T5 dropped the use of the dynarch calendar in favor of a simpler javascript calendar with compatible licensing. Suppose you really want to use dynarch’s js calendar. Before this change, there was no way to supply your own calendar component in place of Tapestry’s default, so even if you had this pretty jscalendar-based component, it wouldn’t be used, unless you did something like add: @DataType(“customdate”) to every one of your date fields, or had a service that changed the DataType for any bean models you create. Now, you can override the built-in, and tapestry picks it up. Nice.

4. Tapestry now supports “Index” pages at the root or in sub-folders. nice feature.

if you have index.tml in the root then http://localhost picks it up
if you have index.tml in a directory called admin, then http://localhost/admin picks it up in addition to http://localhost/admin/index

5. Tapestry pages may now be secured for access only via HTTPS.

just put the @Secure before the page class, however your sever should have https set up.

6. Added the FormFragment component to allow for forms that are mutable on the client-side. In addition, the Form component may now update a Zone.
7. Hibernate ValueEncoder.
Use an entity as a page or event context and what goes in the URL is the entity’s id. Likewise, ids are turned back into entities when passed to event handler methods. Sample:

public class UserEdit {

    private User user;
    public void onActivate(User obj) {
        user = obj;
   	User onPassivate() { return user; } // this is important, omit this, nothing will be updated when you click update
    Class onSuccess() {
     	// do something here.
Tagged with: , ,

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: