public PrettyConfig build() { final PrettyConfig config = new PrettyConfig(); config.setMappings(mappings); config.setGlobalRewriteRules(rewriteRules); return config; } }
public String getDynaViewId() { return config.getDynaviewId(); }
public void addFromConfig(PrettyConfig config) { if (config != null) { mappings.addAll(config.getMappings()); rewriteRules.addAll(config.getGlobalRewriteRules()); } }
if (context.getConfig().isMappingId(viewId)) urlMapping = context.getConfig().getMappingById(viewId); viewId = urlMapping.getViewId(); ExtractedValuesURLBuilder builder = new ExtractedValuesURLBuilder();
/** * Discover if the given id is a {@link UrlMapping} id specified in the current configuration. * * @return True if the id is found, false if not. */ public boolean isMappingId(final String id) { UrlMapping mapping = getMappingById(id); return mapping instanceof UrlMapping; }
public PrettyConfig processConfiguration(ServletContext context, PrettyConfig config) { String enabled = context.getInitParameter(HIERARCHY_ENABLED_PARAM); if ((enabled != null) && "false".equalsIgnoreCase(enabled.trim())) { return config; } List<UrlMapping> mappings = config.getMappings(); for (UrlMapping m : mappings) { createAncestry(config, m); } return config; }
matches.add(prettyConfig.getMappingById(mappingId)); for (UrlMapping m : prettyConfig.getMappings())
@Override public PrettyConfig loadConfiguration(ServletContext sc) { WebXmlParser webXmlParser = new WebXmlParser(); try { webXmlParser.parse(sc); } catch (IOException ex) { throw new RuntimeException(ex); } catch (SAXException ex) { throw new RuntimeException(ex); } BeanManager beanManager = (BeanManager) sc.getAttribute(BeanManagerServletContextListener.BEANMANAGER_SERVLETCONTEXT_KEY); ViewConfigStore store = BeanManagerUtils.getContextualInstance(beanManager, ViewConfigStore.class); List<UrlMapping> mappings = loadUrlMappings(store, webXmlParser.getFacesMapping()); PrettyConfig prettyConfig = new PrettyConfig(); prettyConfig.setMappings(mappings); return prettyConfig; }
/** * Get the {@link UrlMapping} representing the current request. */ public UrlMapping getCurrentMapping() { if (currentMapping == null) { currentMapping = config.getMappingForUrl(requestURL); } return currentMapping; }
public PrettyConfig getConfig() { if ((servletContext == null) || (servletContext.getAttribute(PrettyContext.CONFIG_KEY) == null)) { log.warn("PrettyFilter is not registered in web.xml, but is registered with JSF " + "Navigation and Action handlers -- this could cause unpredictable behavior."); return new PrettyConfig(); } return (PrettyConfig) servletContext.getAttribute(PrettyContext.CONFIG_KEY); }
private String rewrite(final String url) { String result = ""; if (url != null) { String strippedUrl = stripContextPath(url); if (!strippedUrl.equals(url)) { result = contextPath; } try { for (RewriteRule c : prettyConfig.getGlobalRewriteRules()) { strippedUrl = rewriteEngine.processOutbound(request, this, c, strippedUrl); } result += strippedUrl; } catch (Exception e) { throw new PrettyException("Error occurred during canonicalization of request <[" + url + "]>", e); } } return result; }
private boolean isPrettyNavigationCase(final PrettyContext prettyContext, final String action) { PrettyConfig config = prettyContext.getConfig(); return (action != null) && config.isMappingId(action) && action.trim().startsWith(PrettyContext.PRETTY_PREFIX); } }
private void encodeURL(ExternalContext externalContext, PrettyConfig config, String target) throws IOException { String redirectUrl = externalContext.encodeActionURL(target); if (config.isUseEncodeUrlForRedirects()) { redirectUrl = ((HttpServletResponse) externalContext.getResponse()).encodeURL(redirectUrl); } else { redirectUrl = ((HttpServletResponse) externalContext.getResponse()).encodeRedirectURL(redirectUrl); } externalContext.redirect(redirectUrl); }
config.setDynaviewId(getFacesDynaViewId());
return navigationCase; else if ((outcome != null) && outcome.startsWith(PrettyContext.PRETTY_PREFIX) && config.isMappingId(outcome)) UrlMapping mapping = config.getMappingById(outcome); String viewId = mapping.getViewId(); if (mapping.isDynaView())
/** * Discover if the given id is a {@link UrlMapping} id specified in the current configuration. * * @return True if the id is found, false if not. */ public boolean isMappingId(final String id) { UrlMapping mapping = getMappingById(id); return mapping instanceof UrlMapping; }
public PrettyConfig processConfiguration(ServletContext context, PrettyConfig config) { String enabled = context.getInitParameter(HIERARCHY_ENABLED_PARAM); if ((enabled != null) && "false".equalsIgnoreCase(enabled.trim())) { return config; } List<UrlMapping> mappings = config.getMappings(); for (UrlMapping m : mappings) { createAncestry(config, m); } return config; }
matches.add(prettyConfig.getMappingById(mappingId)); for (UrlMapping m : prettyConfig.getMappings())
/** * Get the {@link UrlMapping} representing the current request. */ public UrlMapping getCurrentMapping() { if (currentMapping == null) { currentMapping = config.getMappingForUrl(requestURL); } return currentMapping; }
public PrettyConfig getConfig() { if ((servletContext == null) || (servletContext.getAttribute(PrettyContext.CONFIG_KEY) == null)) { log.warn("PrettyFilter is not registered in web.xml, but is registered with JSF " + "Navigation and Action handlers -- this could cause unpredictable behavior."); return new PrettyConfig(); } return (PrettyConfig) servletContext.getAttribute(PrettyContext.CONFIG_KEY); }