Search in sources :

Example 6 with MockPageContext

use of org.springframework.web.testfixture.servlet.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.web.testfixture.servlet.MockPageContext) JspAwareRequestContext(org.springframework.web.servlet.support.JspAwareRequestContext) RequestContext(org.springframework.web.servlet.support.RequestContext)

Aggregations

MockPageContext (org.springframework.web.testfixture.servlet.MockPageContext)6 RequestContext (org.springframework.web.servlet.support.RequestContext)4 HashMap (java.util.HashMap)2 Map (java.util.Map)2 JspAwareRequestContext (org.springframework.web.servlet.support.JspAwareRequestContext)2 MockHttpServletRequest (org.springframework.web.testfixture.servlet.MockHttpServletRequest)2 PageContext (jakarta.servlet.jsp.PageContext)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 MockHttpServletResponse (org.springframework.web.testfixture.servlet.MockHttpServletResponse)1 MockServletContext (org.springframework.web.testfixture.servlet.MockServletContext)1