Search in sources :

Example 6 with MockPageContext

use of org.springframework.mock.web.test.MockPageContext in project spring-framework by spring-projects.

the class AbstractHtmlElementTagTests method exposeBindingResult.

protected void exposeBindingResult(Errors errors) {
    // wrap errors in a Model
    Map<String, Object> model = Collections.singletonMap(BindingResult.MODEL_KEY_PREFIX + COMMAND_NAME, errors);
    // replace the request context with one containing the errors
    MockPageContext pageContext = getPageContext();
    RequestContext context = new RequestContext((HttpServletRequest) pageContext.getRequest(), model);
    pageContext.setAttribute(RequestContextAwareTag.REQUEST_CONTEXT_PAGE_ATTRIBUTE, context);
}
Also used : MockPageContext(org.springframework.mock.web.test.MockPageContext) JspAwareRequestContext(org.springframework.web.servlet.support.JspAwareRequestContext) RequestContext(org.springframework.web.servlet.support.RequestContext)

Aggregations

MockPageContext (org.springframework.mock.web.test.MockPageContext)6 RequestContext (org.springframework.web.servlet.support.RequestContext)4 HashMap (java.util.HashMap)2 Map (java.util.Map)2 MockHttpServletRequest (org.springframework.mock.web.test.MockHttpServletRequest)2 JspAwareRequestContext (org.springframework.web.servlet.support.JspAwareRequestContext)2 PageContext (javax.servlet.jsp.PageContext)1 MockHttpServletResponse (org.springframework.mock.web.test.MockHttpServletResponse)1 MockServletContext (org.springframework.mock.web.test.MockServletContext)1 StaticWebApplicationContext (org.springframework.web.context.support.StaticWebApplicationContext)1 LocaleResolver (org.springframework.web.servlet.LocaleResolver)1 SimpleWebApplicationContext (org.springframework.web.servlet.SimpleWebApplicationContext)1 ThemeResolver (org.springframework.web.servlet.ThemeResolver)1 AcceptHeaderLocaleResolver (org.springframework.web.servlet.i18n.AcceptHeaderLocaleResolver)1 FixedThemeResolver (org.springframework.web.servlet.theme.FixedThemeResolver)1