List of usage examples for org.springframework.web.servlet.support JspAwareRequestContext JspAwareRequestContext
public JspAwareRequestContext(PageContext pageContext)
From source file:org.parancoe.web.test.junit4.AbstractJspTest.java
/** * Reset all contexts.//from w w w . j a v a 2 s. co m */ protected void resetContexts() { GenericWebApplicationContext context = (GenericWebApplicationContext) applicationContext; ServletContext servletContext = context.getServletContext(); pageContext = new MockPageContext(servletContext, request, response); requestContext = new JspAwareRequestContext(pageContext); pageContext.setAttribute(RequestContextAwareTag.REQUEST_CONTEXT_PAGE_ATTRIBUTE, requestContext); }
From source file:org.gvnix.datatables.tags.SpringContextHelper.java
/** * Returns the current request Spring {@link RequestContext} object. If a * {@link RequestContext} is not already available, a new one is created and * included in the {@link PageContext}//from w ww . j av a2 s. co m * * @param pageContext the current page context * @return the {@link RequestContext} related to this request. */ public RequestContext getRequestContext(PageContext pageContext) { RequestContext requestContext = (RequestContext) pageContext .getAttribute(RequestContextAwareTag.REQUEST_CONTEXT_PAGE_ATTRIBUTE); if (requestContext == null) { requestContext = new JspAwareRequestContext(pageContext); pageContext.setAttribute(RequestContextAwareTag.REQUEST_CONTEXT_PAGE_ATTRIBUTE, requestContext); } return requestContext; }
From source file:org.hdiv.web.servlet.tags.form.AbstractHtmlElementTagTests.java
protected MockPageContext createAndPopulatePageContext() throws JspException { MockPageContext pageContext = createPageContext(); MockHttpServletRequest request = (MockHttpServletRequest) pageContext.getRequest(); RequestContext requestContext = new JspAwareRequestContext(pageContext); pageContext.setAttribute(RequestContextAwareTag.REQUEST_CONTEXT_PAGE_ATTRIBUTE, requestContext); extendRequest(request);/*w w w .ja v a 2s . com*/ extendPageContext(pageContext); return pageContext; }
From source file:org.openmrs.web.taglib.OpenmrsRequestContextAwareBodyTag.java
/** * After tag body has been evaluated and buffered this creates and exposes the current RequestContext. Delegates to * {@link #doEndTagInternal()} for actual work. *///from w w w. jav a 2 s.c o m @Override public final int doEndTag() throws JspException { try { // get request content available from pageContext this.requestContext = (RequestContext) this.pageContext .getAttribute(RequestContextAwareTag.REQUEST_CONTEXT_PAGE_ATTRIBUTE); // if request context is not specified, create empty request context and set it into pageContext if (this.requestContext == null) { this.requestContext = new JspAwareRequestContext(this.pageContext); this.pageContext.setAttribute(RequestContextAwareTag.REQUEST_CONTEXT_PAGE_ATTRIBUTE, this.requestContext); } // do actual work of this tag return doEndTagInternal(); } catch (JspException ex) { logger.error(ex.getMessage(), ex); throw ex; } catch (RuntimeException ex) { logger.error(ex.getMessage(), ex); throw ex; } catch (Exception ex) { logger.error(ex.getMessage(), ex); throw new JspTagException(ex.getMessage()); } }
From source file:org.parancoe.web.test.TagTest.java
/** * Reset the request and the response, maintaining the same session. Useful, for example, to * call a post after calling the get of the form. */// ww w . ja v a 2 s.c o m protected void resetRequestAndResponse() { HttpSession httpSession = null; // preparing the multipart request if (mpReq != null) { httpSession = mpReq.getSession(); } mpReq = new MockMultipartHttpServletRequest(); mpReq.setSession(httpSession); mpReq.setMethod("GET"); // preparing the normal request if (req != null) { httpSession = req.getSession(); } req = new MockHttpServletRequest(); req.setSession(httpSession); req.setMethod("GET"); req.setContextPath("/testctx"); req.setRequestURI("/testctx/test/request/uri"); req.setAttribute(WebUtils.FORWARD_REQUEST_URI_ATTRIBUTE, "/testctx/test/forward/request/uri"); req.setQueryString("p1=v1&p2=v2&p3=v3"); res = new MockHttpServletResponse(); pc = new MockPageContext(((WebApplicationContext) this.getApplicationContext()).getServletContext(), req, res); rc = new JspAwareRequestContext(pc); pc.setAttribute(RequestContextAwareTag.REQUEST_CONTEXT_PAGE_ATTRIBUTE, rc); }
From source file:org.springframework.web.servlet.tags.RequestContextAwareTag.java
/** * Create and expose the current RequestContext. * Delegates to {@link #doStartTagInternal()} for actual work. * @see #REQUEST_CONTEXT_PAGE_ATTRIBUTE// w w w. j a v a 2s . c o m * @see org.springframework.web.servlet.support.JspAwareRequestContext */ @Override public final int doStartTag() throws JspException { try { this.requestContext = (RequestContext) this.pageContext.getAttribute(REQUEST_CONTEXT_PAGE_ATTRIBUTE); if (this.requestContext == null) { this.requestContext = new JspAwareRequestContext(this.pageContext); this.pageContext.setAttribute(REQUEST_CONTEXT_PAGE_ATTRIBUTE, this.requestContext); } return doStartTagInternal(); } catch (JspException | RuntimeException ex) { logger.error(ex.getMessage(), ex); throw ex; } catch (Exception ex) { logger.error(ex.getMessage(), ex); throw new JspTagException(ex.getMessage()); } }