/** * Returns the page key for a content type listing page without navegation key. * @param contentType Content type of the page. * @return The requested key. */ public static PageKey contentType(ContentType contentType) { return new ContentTypePage(NavigationKey.contentType(contentType)); }
/** Component execution. */ public ComponentResponse execute() { if (config == null) { return ComponentResponse.OK; } final ContentType contentType = config.contentType(); final boolean keepCategory = config.keepCategory().booleanValue(); final boolean keepTag = config.keepTag().booleanValue(); if (navigationKey == null) { if (contentType != null) { navigationKey = NavigationKey.contentType(contentType); } } else { if (keepCategory && navigationKey.isCategory()) { navigationKey = NavigationKey.category(navigationKey.getCategory(), contentType); } else if (keepTag && navigationKey.isTag()) { navigationKey = NavigationKey.tag(navigationKey.getTag(), contentType); } else if (contentType != null) { navigationKey = NavigationKey.contentType(contentType); } else { navigationKey = null; } } return ComponentResponse.OK; }
private CloudItem createItem(ContentType contentType, int hits, int totalHits) { final NavigationKey nk = NavigationKey.contentType(contentType); final PageKey pk = PageKey.navigation(nk); final Route r = (route != null) ? route.toPage(pk) : Route.of(false, pk, null, null); final URI uri = uriGenerator.getURI(r); final Name name = (locale != null) ? contentType.getName().get(locale) : contentType.getDefaultName(); return new CloudItem(name.getDisplayName(), uri, Math.ceil(hits / totalHits)); } }
/** Component execution. */ public ComponentResponse execute() { ContentType c = getDestination(); if (c == null) { // Nothing to do return ComponentResponse.OK; } NavigationKey nk = navigationKey; if (nk == null || !keepNavigationKey) { nk = NavigationKey.contentType(c); } else { nk = nk.withContentType(c); } final PageKey pk = PageKey.navigation(nk); final Route r = getRoute().toPage(pk); // External if (type != null && type.booleanValue()) { return ComponentResponse.seeOther(replaceQuery(getUriGenerator().getAbsoluteURI(r), query)); } else { return ComponentResponse.internal(r); } }
protected MenuItem createItem(ContentType contentType) { final NavigationKey nk; if (config.navigation() && context.getNavigationKey() != null && context.getNavigationKey().isCategory()) { nk = NavigationKey.category(context.getNavigationKey().getCategory(), contentType); } else { nk = NavigationKey.contentType(contentType); } final PageKey pk = PageKey.navigation(nk); final Route r = (route != null) ? route.toPage(pk) : Route.of(false, pk, null, null); final URI uri = uriGenerator.getURI(r); final Name name = (locale != null) ? contentType.getName().get(locale) : contentType.getDefaultName(); final MenuItem item = new MenuItem(name.getDisplayName(), uri); return item; }