@Test public void testGetNavigationCaseForNavigateOutcome() { ConfigurableNavigationHandler parent = mock(ConfigurableNavigationHandler.class); FacesContext facesContext = mock(FacesContext.class); NavigationCase navigationCase = mock(NavigationCase.class); when(parent.getNavigationCase(facesContext, "something", "/viewId.xhtml")).thenReturn(navigationCase); RewriteNavigationHandler handler = new RewriteNavigationHandler(parent); NavigationCase result = handler.getNavigationCase(facesContext, "something", "rewrite-redirect:/viewId.xhtml?param1=foo&param2=bar"); assertEquals(navigationCase, result); }
@Override public NavigationCase getNavigationCase(final FacesContext context, final String fromAction, final String outcome) { if (REWRITE_PREFIX.equals(outcome)) { String viewId = context.getViewRoot().getViewId(); NavigationCase navigationCase = parent.getNavigationCase(context, fromAction, viewId); return navigationCase; } else if (outcome != null && outcome.startsWith(REDIRECT_PREFIX)) { String url = outcome.substring(REDIRECT_PREFIX.length()); String viewId = AddressBuilder.create(url).getPath(); return parent.getNavigationCase(context, fromAction, viewId); } else { NavigationCase navigationCase = parent.getNavigationCase(context, fromAction, outcome); return navigationCase; } }
RewriteNavigationHandler extends ConfigurableNavigationHandler { @Override public NavigationCase getNavigationCase(final FacesContext context, final String fromAction, final String outcome) { if (REWRITE_PREFIX.equals(outcome)) { String viewId = context.getViewRoot().getViewId(); NavigationCase navigationCase = parent.getNavigationCase(context, fromAction, viewId); return navigationCase; } else if (outcome != null && outcome.startsWith(REDIRECT_PREFIX)) { String url = outcome.substring(REDIRECT_PREFIX.length()); String viewId = AddressBuilder.create(url).getPath(); return parent.getNavigationCase(context, fromAction, viewId); } else { NavigationCase navigationCase = parent.getNavigationCase(context, fromAction, outcome); return navigationCase; } } }
RewriteNavigationHandler extends ConfigurableNavigationHandler { @Override public NavigationCase getNavigationCase(final FacesContext context, final String fromAction, final String outcome) { if (REWRITE_PREFIX.equals(outcome)) { String viewId = context.getViewRoot().getViewId(); NavigationCase navigationCase = parent.getNavigationCase(context, fromAction, viewId); return navigationCase; } else if (outcome != null && outcome.startsWith(REDIRECT_PREFIX)) { String url = outcome.substring(REDIRECT_PREFIX.length()); String viewId = AddressBuilder.create(url).getPath(); return parent.getNavigationCase(context, fromAction, viewId); } else { NavigationCase navigationCase = parent.getNavigationCase(context, fromAction, outcome); return navigationCase; } } RewriteNavigationHandler(final ConfigurableNavigationHandler parent); }
RewriteNavigationHandler extends ConfigurableNavigationHandler { @Override public NavigationCase getNavigationCase(final FacesContext context, final String fromAction, final String outcome) { if (REWRITE_PREFIX.equals(outcome)) { String viewId = context.getViewRoot().getViewId(); NavigationCase navigationCase = parent.getNavigationCase(context, fromAction, viewId); return navigationCase; } else if (outcome != null && outcome.startsWith(REDIRECT_PREFIX)) { String url = outcome.substring(REDIRECT_PREFIX.length()); String viewId = AddressBuilder.create(url).getPath(); return parent.getNavigationCase(context, fromAction, viewId); } else { NavigationCase navigationCase = parent.getNavigationCase(context, fromAction, outcome); return navigationCase; } } RewriteNavigationHandler(final ConfigurableNavigationHandler parent); @Override void handleNavigation(final FacesContext context, final String fromAction, final String outcome); static boolean isInNavigation(final HttpServletRequest request); @Override NavigationCase getNavigationCase(final FacesContext context, final String fromAction, final String outcome); @Override Map<String, Set<NavigationCase>> getNavigationCases(); @Override void performNavigation(final String outcome); }
RewriteNavigationHandler extends ConfigurableNavigationHandler { @Override public NavigationCase getNavigationCase(final FacesContext context, final String fromAction, final String outcome) { if (REWRITE_PREFIX.equals(outcome)) { String viewId = context.getViewRoot().getViewId(); NavigationCase navigationCase = parent.getNavigationCase(context, fromAction, viewId); return navigationCase; } else if (outcome != null && outcome.startsWith(REDIRECT_PREFIX)) { String url = outcome.substring(REDIRECT_PREFIX.length()); String viewId = AddressBuilder.create(url).getPath(); return parent.getNavigationCase(context, fromAction, viewId); } else { NavigationCase navigationCase = parent.getNavigationCase(context, fromAction, outcome); return navigationCase; } } RewriteNavigationHandler(final ConfigurableNavigationHandler parent); @Override void handleNavigation(final FacesContext context, final String fromAction, final String outcome); static boolean isInNavigation(final HttpServletRequest request); @Override NavigationCase getNavigationCase(final FacesContext context, final String fromAction, final String outcome); @Override Map<String, Set<NavigationCase>> getNavigationCases(); @Override void performNavigation(final String outcome); static final String REDIRECT_PREFIX; }