}
@Override
public boolean dispatch(final Request tapestryRequest, final Response tapestryResponse)
throws IOException {
final PageRenderRequestParameters requestParameters = this.componentEventLinkEncoder
.decodePageRenderRequest(tapestryRequest);
if (requestParameters == null) {
return false;
}
final Component previousPage;
final BreadCrumbList breadCrumbList = this.applicationStateManager.get(BreadCrumbList.class);
if (breadCrumbList.size() > 0) {
final BreadCrumbInfo lastCrumb = breadCrumbList.getLastCrumb();
previousPage = this.componentSource.getPage(lastCrumb.getPageName());
} else {
previousPage = null;
}
/* Is the requested page tagged with BreadCrumb- or BreadCrumbReset-annotation? */
final Component page = this.componentSource.getPage(requestParameters.getLogicalPageName());
final BreadCrumbReset reset = this.findAnnotation(page.getClass(), BreadCrumbReset.class);
if (reset != null) {
if (previousPage == null
|| !this.previousPageIsIgnored(previousPage.getClass(), reset.ignorePages())) {
breadCrumbList.reset();
}
}
final BreadCrumbInfo breadCrumbInfo;
final BreadCrumb annotation = this.findAnnotation(page.getClass(), BreadCrumb.class);
if (annotation != null) {
final String titleKey = annotation.titleKey();
final EventContext context = requestParameters.getActivationContext();
final Link link = this.pageRenderLinkSource.createPageRenderLinkWithContext(
requestParameters.getLogicalPageName(), context);
breadCrumbInfo = new BreadCrumbInfo(titleKey, link,
requestParameters.getLogicalPageName());
} else {
breadCrumbInfo = new BreadCrumbInfo(requestParameters.getLogicalPageName());
}
breadCrumbList.add(breadCrumbInfo);
return false;
}