Category Archives: tapestry5

tapestry 5 release candidate

Great news, tapestry 5.0.16 has been released. This is the first release candidate and expectation is that the release version will be available in less than a month.

While tapestry 5 has been production ready for quite some time now, this is a major step forward for adoption of this wonderful framework.

Major selling point is the component based way of building pages and clean separation between code and template.
If you want to see how things are done in tapestry 5, have a look at the jumpstart project, which contains great tutorials.

With some good component libraries (like chenillekit and its predecessor t5components) we are on our way to build some nice stuff. Chenillkit itself is also nearing release status for all components. Some good stuff like the access module (which I dearly need) are fast moving forward.

equanda 0.9.1 released

The equanda project has released a new version.

equanda is a an open source framework which allows generation of a base JEE application, including DAO layer and tapestry5 based user interface from a domain model. The DAO layer uses a EJB3 backend with possibility for powerful declarative constraints and added programmatic constraints. The user interface is component based and allows extensive customizations and re-use of components for custom pages. The project also contains a generic reusable set of tapestry components and general utility code.

This is a further step to making it more feature complete, moving towards v1.

Notable changes include :

  • multiple select in generated linklist
  • inline link components which avoid page navigation
  • a Display component which only displays, and does not allow edit is now generated
  • compare constraint for link field which limits the linked records to have the right type
  • accordion component can remember state
  • new ValidationTrackerDelegate component
  • upgrade to tapestry 5.0.14
  • many smaller improvements and bugfixes

Full release notes are here.

tapestry5 reporting messages when the ValidationTracker is not available

Sometimes, you run into some tricky problems. I have some pages which need to be externally invocable using parameters. This is perfectly handled in tapestry using the activation context and or extraction of extra parameters from the Request object. However, when handling this information, I may raise a problem and this needs to be reported. This should be done using the normal error reporting in the component.

The solution I built for this (and will be part of part of the next release (0.9.1) of equanda-tapestry5 components is the ValidationTrackerDelegate. This allows you to post your message in the tapestry Environment, and the message is retrieved from that to be displayed on your page. For this to work, your page template should contain something like (note that the order of the components is important).

<t:form>
    <t:equanda.ValidationTrackerDelegate/>
    <t:errors/>

    .....

</t:form>

In your page, the message need to be stored in the environment in the beginRender event. So your page code will look something like

@Inject
private Environment environment;

private String keepMessage;

public void onActivate()
{
    .... do whatever needs to be done

    .... if there is a problem do the following
    keepMessage = "error message";
}

void beginRender()
{
    if ( null != keepMessage ) environment.push( MessageContainer.class, new MessageContainer( keepMessage ) );
}

void endRender()
{
    if ( null != keepMessage ) environment.pop( MessageContainer.class );
}

The actual component is very simple. We need a class to store the message in the environment (aptly named MessageContainer in this example).

public class MessageContainer
{
    private String message;

    public MessageContainer( String message )
    {
        this.message = message;
    }

    public String getMessage()
    {
        return message;
    }
}

The actual component then becomes almost trivial. From inside the form (where the ValidationTracker is available, and before it is used in the errors component), the following is done.

public class ValidationTrackerDelegate
{
    @Inject
    private Environment environment;

    @Environmental
    private ValidationTracker validationTracker;

    boolean beginRender()
    {
        MessageContainer mc = environment.peek( MessageContainer.class );

        if ( mc != null )
        {
            validationTracker.recordError( mc.getMessage() );
        }

        return false;
    }
}