public void injectParameters(final FacesContext context) { log.trace("Injecting parameters"); PrettyContext prettyContext = PrettyContext.getCurrentInstance(context); URL url = prettyContext.getRequestURL(); UrlMapping mapping = prettyContext.getCurrentMapping(); if (mapping != null) { injectPathParams(context, url, mapping); injectQueryParams(context, mapping, prettyContext); } }
/** * Package private -- only {@link PrettyFilter} should be calling this method * -- it does not overwrite existing contexts in Request object */ static PrettyContext newDetachedInstance(final HttpServletRequest request) { Assert.notNull(request, "HttpServletRequest argument was null"); PrettyContext prettyContext = new PrettyContext(request); return prettyContext; }
private boolean isPrettyNavigationCase(final String action) { PrettyContext prettyContext = PrettyContext.getCurrentInstance(); PrettyConfig config = prettyContext.getConfig(); return action != null && config.isMappingId(action) && action.trim().startsWith(PrettyContext.PRETTY_PREFIX); } }
/** * @return True if the current mapping and request should trigger DynaView * capabilities. */ public boolean shouldProcessDynaview() { if (isPrettyRequest()) { return getCurrentMapping().isDynaView() && !isDynaviewProcessed(); } return false; }
/** * URL Tracking: */ public String getPageURLWithQueryString() { return PrettyContext.getCurrentInstance().getRequestURL().toURL() + PrettyContext.getCurrentInstance().getRequestQueryString().toQueryString(); }
/** * Return true if the given URL corresponds to one or more mappings in the * current configuration. Strips context path information if necessary. */ public boolean isURLMapped(final String url) { return getConfig().isURLMapped(stripContextPath(url)); }
if(!PrettyContext.isInstantiated(request)) { reloader.onNewRequest(servletContext); req.setAttribute(PrettyContext.CONFIG_KEY, getConfig()); PrettyContext context = PrettyContext.newDetachedInstance(request); URL url = context.getRequestURL(); context.setCurrentMapping(mapping); PrettyContext.setCurrentContext(request, context); // set String viewId = context.getCurrentViewId(); if (!response.isCommitted()) if (context.shouldProcessDynaview()) req.getRequestDispatcher(context.getDynaViewId()).forward(req, response); List<PathParameter> params = context.getCurrentMapping().getPatternParser().parse(url); QueryString query = QueryString.build(params);
PrettyContext prettyContext = PrettyContext.getCurrentInstance(context); PrettyConfig config = prettyContext.getConfig(); ExternalContext externalContext = context.getExternalContext(); String contextPath = prettyContext.getContextPath(); if (PrettyContext.PRETTY_PREFIX.equals(action) && prettyContext.isPrettyRequest()) URL url = prettyContext.getRequestURL(); QueryString query = prettyContext.getRequestQueryString();
if (urlMapping != null) PrettyContext context = PrettyContext.getCurrentInstance(facesContext); if (context.getConfig().isMappingId(viewId)) urlMapping = context.getConfig().getMappingById(viewId); viewId = urlMapping.getViewId(); ExtractedValuesURLBuilder builder = new ExtractedValuesURLBuilder(); result = context.getContextPath() + builder.buildURL(urlMapping).encode() + builder.buildQueryString(urlMapping); result = context.stripContextPath(result);
@Override public String getActionURL(final FacesContext context, final String viewId) { PrettyContext prettyContext = PrettyContext.getCurrentInstance(context); if (prettyContext.isPrettyRequest() && !prettyContext.isInNavigation() && (viewId != null) && viewId.equals(context.getViewRoot().getViewId())) { URL url = prettyContext.getRequestURL(); QueryString query = prettyContext.getRequestQueryString(); String contextPath = prettyContext.getContextPath(); String target = contextPath + url + query.toQueryString(); return target; } else { return parent.getActionURL(context, viewId); } }
public String _getActionURL(final FacesContext context, final String viewId) { PrettyContext prettyContext = PrettyContext.getCurrentInstance(context); String result = null; if (prettyContext.isPrettyRequest() && (viewId != null) && viewId.equals(context.getViewRoot().getViewId())) { ExtractedValuesURLBuilder builder = new ExtractedValuesURLBuilder(); UrlMapping mapping = prettyContext.getCurrentMapping(); result = prettyContext.getContextPath() + builder.buildURL(mapping) + builder.buildQueryString(mapping); } return result; }
PrettyContext prettyContext = PrettyContext.getCurrentInstance(context); log.trace("Invoking method: " + action + ", on request: " + prettyContext.getRequestURL()); Object result = elUtils.invokeMethod(context, action.getAction().getELExpression()); if (result != null) handler.handleNavigation(context, prettyContext.getCurrentViewId(), outcome);
/** * Calculate the Faces ViewId to which this request URI resolves. This method will recursively call any dynamic * mapping viewId functions as needed until a String viewId is returned, or supplied by a static mapping. * <p> * This phase does not support FacesNavigation or PrettyRedirecting. Its SOLE purpose is to resolve a viewId. * <p> * <i><b>Note:</b> Precondition - parameter injection must take place before this</i> * <p> * <i>Postcondition - currentViewId is set to computed View Id</i> * * @param facesContext2 * * @return JSF viewID to which this request resolves. */ public String computeDynaViewId(final FacesContext facesContext) { PrettyContext context = PrettyContext.getCurrentInstance(facesContext); UrlMapping urlMapping = context.getCurrentMapping(); return calculateDynaviewId(facesContext, urlMapping); }
PrettyContext context = PrettyContext.getCurrentInstance(httpServletRewrite.getRequest()); REWRITE_MAPPING_ID_KEY + ":" + mapping.getId()); URL url = context.getRequestURL(); if (context.shouldProcessDynaview()) log.trace("Forwarding mapped request [" + url.toURL() + "] to dynaviewId [" + context.getDynaViewId() + "]"); ((HttpInboundServletRewrite) event).forward(context.getDynaViewId()); String newUrl = rewritePrettyMappings(context.getConfig(), httpServletRewrite.getContextPath(), outboundRewrite.getOutboundAddress().toString()); outboundRewrite.setOutboundAddress(AddressBuilder.create(newUrl));
@Override public Map<String, String[]> getAdditionalParameters(final ServletRequest request, final ServletResponse response) { PrettyContext context = PrettyContext.getCurrentInstance((HttpServletRequest)request); PrettyConfig config = context.getConfig(); URL url = context.getRequestURL(); if (config.isURLMapped(url)) { List<PathParameter> params = context.getCurrentMapping().getPatternParser().parse(url); QueryString query = QueryString.build(params); return query.getParameterMap(); } return null; }
/** * Handle DynaView processing. This method will end the Faces life-cycle. */ public void processDynaView(final PrettyContext prettyContext, final FacesContext facesContext) { log.trace("Requesting DynaView processing for: " + prettyContext.getRequestURL()); String viewId = ""; try { viewId = prettyContext.getCurrentViewId(); log.trace("Invoking DynaView method: " + viewId); Object result = computeDynaViewId(facesContext); if (result instanceof String) { viewId = (String) result; log.trace("Forwarding to DynaView: " + viewId); prettyContext.setDynaviewProcessed(true); facesContext.getExternalContext().dispatch(viewId); facesContext.responseComplete(); } } catch (Exception e) { log.error("Failed to process dynaview", e); PrettyRedirector prettyRedirector = new PrettyRedirector(); prettyRedirector.send404(facesContext); throw new PrettyException("Could not forward to view: " + viewId + "", e); } }
PrettyContext prettyContext = PrettyContext.getCurrentInstance(behaviorContext.getFacesContext()); if (prettyContext == null) UrlMapping mapping = prettyContext.getConfig().getMappingById(mappingId.trim()); if (mapping == null) String contextPath = prettyContext.getContextPath(); String path = contextPath + builder.buildURL(mapping) + builder.buildQueryString(mapping);
public void injectParameters(final FacesContext context) { PrettyContext prettyContext = PrettyContext.getCurrentInstance(); String url = prettyContext.stripContextPath(prettyContext.getOriginalUri()); for (PrettyUrlMapping mapping : prettyContext.getConfig().getMappings()) { UrlPatternParser parser = new UrlPatternParser(mapping.getPattern()); if (parser.matches(url)) { injectParams(context, url, mapping, parser); injectQueryParams(context, mapping); } } }
@Override public String getActionURL(final FacesContext context, final String viewId) { PrettyContext prettyContext = PrettyContext.getCurrentInstance(); if (prettyContext.isPrettyRequest() && !prettyContext.isInNavigation() && (viewId != null) && viewId.equals(context.getViewRoot().getViewId())) { return context.getExternalContext().encodeActionURL(prettyContext.getCalculatedActionUri()); } else { return parent.getActionURL(context, viewId); } }
PrettyContext prettyContext = PrettyContext.getCurrentInstance(); PrettyConfig config = prettyContext.getConfig(); ExternalContext externalContext = context.getExternalContext(); if (PrettyContext.PRETTY_PREFIX.equals(action) && prettyContext.isPrettyRequest()) String url = prettyContext.getOriginalRequestUrl(); log.info("Refreshing requested page [" + url + "]"); externalContext.redirect(externalContext.encodeActionURL(url));