private Class<?> getCurrentPage() { if (navigation.getCurrentPage() != null) { return navigation.getCurrentPage().contentType(); } else { // Guaranteed to exist at compile-time. return navigation.getPagesByRole(DefaultPage.class).iterator().next().contentType(); } }
/** * Returns an instance of the given page type. If the page is an ApplicationScoped bean, the singleton instance of the * page will be returned; otherwise (for Dependent-scoped beans) a new instance will be returned. * * @param type * The Class object for the bean that implements the page. * @return The appropriate instance of the page. */ public <C> PageNode<C> getPage(Class<C> type) { // TODO this could be made more efficient if we had a pagesByWidgetType map for (Entry<String, PageNode<?>> e : pagesByName.entrySet()) { if (e.getValue().contentType().equals(type)) { @SuppressWarnings({ "unchecked" }) PageNode<C> page = (PageNode<C>) e.getValue(); return page; } } throw new PageNotFoundException("No page with a widget type of " + type.getName() + " exists"); }
@Override public void navigateBackOrHome() { // Guaranteed to exist at compile-time. final PageNode<?> defaultPageNode = navigation.getPagesByRole(DefaultPage.class).iterator().next(); navigateBackOrToPage(defaultPageNode.contentType()); }
private Class<?> getCurrentPage() { if (navigation.getCurrentPage() != null) { return navigation.getCurrentPage().contentType(); } else { // Guaranteed to exist at compile-time. return navigation.getPagesByRole(DefaultPage.class).iterator().next().contentType(); } }
@Override public void navigateBackOrHome() { // Guaranteed to exist at compile-time. final PageNode<?> defaultPageNode = navigation.getPagesByRole(DefaultPage.class).iterator().next(); navigateBackOrToPage(defaultPageNode.contentType()); }
/** * Returns an instance of the given page type. If the page is an ApplicationScoped bean, the singleton instance of the * page will be returned; otherwise (for Dependent-scoped beans) a new instance will be returned. * * @param type * The Class object for the bean that implements the page. * @return The appropriate instance of the page. */ public <C> PageNode<C> getPage(Class<C> type) { // TODO this could be made more efficient if we had a pagesByWidgetType map for (Entry<String, PageNode<?>> e : pagesByName.entrySet()) { if (e.getValue().contentType().equals(type)) { @SuppressWarnings({ "unchecked" }) PageNode<C> page = (PageNode<C>) e.getValue(); return page; } } throw new PageNotFoundException("No page with a widget type of " + type.getName() + " exists"); }