8 Articles


11 years Ago

When @Inject* Silently Fails

Published by Marco on

Most Tapestry programming involves writing event handlers and operations on page objects. In order to execute these operations, you need access to properties of the form and properties of the session and application in which the page resides. For convenience, developers can add references to all sorts of objects in the system using various forms of the @Inject* annotation (like @InjectPage, @InjectObject and so on). Pages are declared abstract and, when instantiated, Tapestry extends the... [More]

Override an implementation in HiveMind

Published by Marco on

If you are not already familier with HiveMind, read Setting up a Service in HiveMind for an introduction.[1]

In the article mentioned above, we learned how to set up a new HiveMind service. What if we want to replace the implementation for an existing service? Is it even possible? Why would you want to do that? This article answers these questions in the context of a real-life example from one of our applications.

Extending Tapestry

In our Tapestry applications, we use the ExternalLink because... [More]

Session and Requests in HiveMind

Published by Marco on

If you are not already familier with HiveMind, read Setting up a Service in HiveMind for an introduction.[1]

Almost every application is going to need to have information that is session-specific. This is accomplished by adding a member to Tapestry’s application objects list and assigning it the proper scope. With a scope of “session”, HiveMind makes sure that each session in the web application has its own copy.

  <contribution configuration-id="tapestry.state.ApplicationObjects">
    <state-object... [More]

Setting up a Service in HiveMind

Published by Marco on

HiveMind is the IOC manager used together with Tapestry; it’s in charge of bootstrapping and connecting all of the myriad objects and services available to a Tapestry application. Applications based on Tapestry are encouraged to use it to configure their application- and session-level objects and services as well.

Once it works, it works well. Getting it configured in the first place—especially when new to HiveMind—is an exercise in patience. Larger errors are detected at startup, when... [More]

Missing ognl?

Published by Marco on

Every once in a while, when adding a new component to or changing an existing one on a Tapestry page, you’ll make a mistake. Most of the time, the exception handler page is pretty good; sometimes the exception can be quite confusing. For example, suppose we have a custom component with a single property:

package com.encodo.blogs.samples;

class CustomComponent extends BaseComponent {
  public abstract SomeObject getCustomParameter();

To use this component in a page, you just write the... [More]

Using @InvokeListener

Published by Marco on

Recursive Components in Tapestry discussed several approaches to nested components in Tapestry, finally settling on a solution that had only the following Java code:

public abstract class DataObjectTree extends BaseComponent {
  public abstract DataObject getContext();

  public Object getBlockContext() {
    return ((Block) getComponents().get("Node")).getParameter("value");

Since the BlockContext is called many times from the component—real-world implementations will also likely... [More]

Recursive Components in Tapestry

Published by Marco on

Given a recursive object structure in memory, what’s the best—and most efficient—way to render it with Tapestry? First, let’s define a tiny Java class that we’ll use for our example:

public class DataObject {
  private String name;
  private List<DataObject> subObjects = new ArrayList<DataObject>();

  public String getName() {
    return name;

  public List<DataObject> getSubObjects() {
    return subObjects;

Imagine an application has built a whole tree of DataObjects and... [More]

Pitfall in the @For component in Tapestry

Published by Marco on

Any properties used from a Tapestry template have to be declared in the corresponding Java page class. It is highly recommended to declare these properties as abstract; Tapestry implements them for you, automatically including code that re-initializes each property automatically when a page is re-used from the cache. If you implement the properties yourself in the customary Java getter/setter way, it is up to you to clear them in order to ensure that users can’t see one another’s data.

That... [More]