Search in sources :

Example 1 with JspAwareRequestContext

use of org.springframework.web.servlet.support.JspAwareRequestContext in project spring-framework by spring-projects.

the class AbstractHtmlElementTagTests method createAndPopulatePageContext.

protected MockPageContext createAndPopulatePageContext() throws JspException {
    MockPageContext pageContext = createPageContext();
    MockHttpServletRequest request = (MockHttpServletRequest) pageContext.getRequest();
    StaticWebApplicationContext wac = (StaticWebApplicationContext) RequestContextUtils.findWebApplicationContext(request);
    wac.registerSingleton("requestDataValueProcessor", RequestDataValueProcessorWrapper.class);
    extendRequest(request);
    extendPageContext(pageContext);
    RequestContext requestContext = new JspAwareRequestContext(pageContext);
    pageContext.setAttribute(RequestContextAwareTag.REQUEST_CONTEXT_PAGE_ATTRIBUTE, requestContext);
    return pageContext;
}
Also used : MockHttpServletRequest(org.springframework.mock.web.test.MockHttpServletRequest) MockPageContext(org.springframework.mock.web.test.MockPageContext) StaticWebApplicationContext(org.springframework.web.context.support.StaticWebApplicationContext) JspAwareRequestContext(org.springframework.web.servlet.support.JspAwareRequestContext) JspAwareRequestContext(org.springframework.web.servlet.support.JspAwareRequestContext) RequestContext(org.springframework.web.servlet.support.RequestContext)

Example 2 with JspAwareRequestContext

use of org.springframework.web.servlet.support.JspAwareRequestContext in project spring-framework by spring-projects.

the class RequestContextAwareTag method doStartTag.

/**
	 * Create and expose the current RequestContext.
	 * Delegates to {@link #doStartTagInternal()} for actual work.
	 * @see #REQUEST_CONTEXT_PAGE_ATTRIBUTE
	 * @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 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());
    }
}
Also used : JspException(javax.servlet.jsp.JspException) JspAwareRequestContext(org.springframework.web.servlet.support.JspAwareRequestContext) JspTagException(javax.servlet.jsp.JspTagException) JspException(javax.servlet.jsp.JspException) JspTagException(javax.servlet.jsp.JspTagException)

Aggregations

JspAwareRequestContext (org.springframework.web.servlet.support.JspAwareRequestContext)2 JspException (javax.servlet.jsp.JspException)1 JspTagException (javax.servlet.jsp.JspTagException)1 MockHttpServletRequest (org.springframework.mock.web.test.MockHttpServletRequest)1 MockPageContext (org.springframework.mock.web.test.MockPageContext)1 StaticWebApplicationContext (org.springframework.web.context.support.StaticWebApplicationContext)1 RequestContext (org.springframework.web.servlet.support.RequestContext)1