static void setupPageContext(HttpServletRequest request, PageContext context) { String q = request.getQueryString(); context.withObject(PageContext.REQUEST_PATH, request.getPathTranslated()); context.withObject(PageContext.REQUEST_URIQ, request.getRequestURI() + (q == null ? "" : "?" + q)); context.withObject(PageContext.SESSION, new SessionAttributesMap(request)); context.withObject(PageContext.REQUEST_PARAMETERS, new RequestParametersMap(request)); context.withObject(PageContext.REQUEST_HEADERS, new RequestHeadersMap(request)); } }
@Override public PageContext withObject(String key, Object value) { LOG.fine("PageContext.["+this.attributes.getDepth()+"].set(" + key + "," + value + ")"); return super.withObject(key, value); }
/** * Dispatch an incoming request to a Renderable component * by looking for a named component that matches the path. */ @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String uri = request.getPathInfo(); Renderable component = this.dispatchMap.get(uri); if (component == null) { response.sendError(404); } else { HtmlCanvas canvas = HtmlCanvasFactory.createCanvas(request,response,response.getWriter()); PageContext context = canvas.getPageContext(); String q = request.getQueryString(); context.withObject(PageContext.REQUEST_PATH, request.getPathTranslated()); context.withObject(PageContext.REQUEST_URIQ, request.getRequestURI() + (q == null ? "" : "?" + q)); context.withObject(PageContext.SESSION, new SessionAttributesMap(request)); context.withObject(PageContext.REQUEST_PARAMETERS, new RequestParametersMap(request)); context.withObject(PageContext.REQUEST_HEADERS, new RequestHeadersMap(request)); canvas.render(component); } }
@Override public HtmlCanvas render(Renderable component) throws IOException { if (null == component) return this; // For debugging, we hide the exception component to reveal the offending component if (!(component instanceof RenderException)) this.getPageContext().withObject(RenderException.KEY_PAGECONTEXT,component); if (enabled) { renderCount++; if (insideBody) { super.render(new Inspector(component)); } else { super.render(component); } } else { super.render(component); } return this; }