1. Dimitris Zenios
  2. tapestry-zbreadcrumbs


Clone wiki

tapestry-zbreadcrumbs / Home


Tapestry-zbreadcrumbs is a yet another bread crumb trail implementation Tapestry 5.It is licensed under The Apache Software License, Version 2.0

Even though it was inspired from tapestry-breadcrumbs it has many differences.Two main differences are

  1. It uses a PageRenderRequestFilter instead of a dispatcher
  2. It does not need an annotation in order to add pages to the trail


  • Configuration through contributions and annotations
  • Dynamic breadcrumb titles
  • Very flexible breadcrumbs trail component




Add the dependency to your POM:


Add the crumb trail component to your template:

<t:zcrumb.BreadCrumbsTrail />


Module Configuration

Many properties of the module can be overridden by contributing to application defaults:

Property NameDefault ValueDescription
BreadCrumbsConstants.BREADCRUMBS_MAX_CRUMBS_TO_SAVE10Number of breadcrumbs to save.If exceeded the list will wrap around.
BreadCrumbsConstants.BREADCRUMBS_DISCARD_DUPLICATEStrueWhether or not to discard duplicate breadcrumbs.
BreadCrumbsConstants.BREADCRUMBS_TRAIL_CSS_CLASSt-zbreadcrumbsDefault class name that is added to the breadCrumbTrailComponent.
BreadCrumbsConstants.BREADCRUMBS_TITLE_SUFFIX-crumbDefault suffix that will be appended to the logical page name when using message catalogue to get the title of the breadcrumb.
BreadCrumbsConstants.BREADCRUMBS_DEFAULT_STYLESHEETclasspath:.../Assets/default.cssThe default breadcrumbs stylesheet automatically injected into every rendered HTML page.

BreadCrumbs configuration

In many cases user needs to exclude a page from beeing added to the breadcrumbs list or even reset the whole list.There are two options to configure such operations:

  1. Using annotations
  2. Using contribution

Using annotations

Annotation BreadCrumb can be added on every page template you want to have control.The annotation has two properties:

  • reset (Reset breadcrumbs list)
  • ignore (Ignore page)

If both annotations are true it will first reset the list and then ignore the page

public class Index {

Using contributions

By contributing to BreadCrumbsService you can control breadcrumb behavior on each page.Configuration though contribution, takes a list of BreadCrumbRule elements.Each BreadCrumbRule element contains a path pattern and a BreadCrumbAttribute (Ignore, Reset)

The mapping matches URLs using the following rules:

  • ? matches one character
  • * matches zero or more characters
  • ** matches zero or more 'directories' in a path

Some examples:

  • index - matches all index files in the root directory
  • com/t?st - matches com/test but also com/tast or com/txst
  • com/* - matches all files in the com directory
  • com/**/test - matches all test files underneath the com path
  • com/zenios/bread/**/* - matches all files underneath the com/zenios/bread path
  • com/**/servlet/bla.jsp - matches com/zenios/bread/servlet/bla.jsp but also com/zenios/bread/testing/servlet/bla.jsp and com/servlet/bla.jsp
public static void contributeBreadCrumbsService(Configuration<BreadCrumbRule> configuration) {
	configuration.add(new BreadCrumbRule("index",BreadCrumbAttribute.IGNORE));
	configuration.add(new BreadCrumbRule("index",BreadCrumbAttribute.RESET));
	configuration.add(new BreadCrumbRule("reports/*",BreadCrumbAttribute.IGNORE));

BreadCrumb titles

BreadCrumb titles are extracted using the following order

  1. Using an event BreadCrumbsEventConstants.GET_TITLE. The component event handler will be passed the activation context
  2. Using message catalogs
  3. Using logical page name

Using an event

An event with name BreadCrumbsEventConstants.GET_TITLE will be triggered on the appropriate component. The component event handler will be passed the activationContext. The returned string, will be used as the page title

public String getBreadCrumbTitle(User user) {
	return user.getUsername();

Using message catalogs

If there is no event handler for the event mentioned above then the title will be retrieved from the components message catalog.The key for the message will be extracted from the logical page name and then append BreadCrumbsConstants.BREADCRUMBS_TITLE_SUFFIX

Index-crumb = Index page

Using logical page name

If there is no event handler and no message then the logical page name will be used as breadcrumb title

BreadCrumbs trail component

Breadcrumbs trail component, is the component responsible for rendering the list of breadcrubs.Main features of the component are

  • Add block before each breadcrumb
  • Add block after each breadcrumb
  • Override the default breadcrumb block
public class testPage {
	private BreadCrumbElement breadCrumb;
	private int index;

	public String getCrumbClass() {
		return getTitle() + "-class";

	public String getTitle() {
		return breadCrumb.getLogicalPageName();
<t:zcrumb.BreadCrumbsTrail t:value="breadCrumb" t:index="index" t:class="literal:testclass" t:crumbClass="crumbClass">

Have in mind that by overridding the default breadCrumb block the methods for getting breadcrumb title mentioned above will not be used.You will be responsible for the rendering of the actual breadcrumb.