Search in sources :

Example 1 with RequestContext

use of org.springframework.web.servlet.support.RequestContext in project head by mifos.

the class SystemInformationController method viewSystemInformation.

@edu.umd.cs.findbugs.annotations.SuppressWarnings(value = "NP_UNWRITTEN_FIELD", justification = "request is not null")
@RequestMapping(method = RequestMethod.GET)
public ModelAndView viewSystemInformation(HttpServletRequest request) {
    ServletContext context = request.getSession().getServletContext();
    RequestContext requestContext = new RequestContext(request);
    Locale locale = requestContext.getLocale();
    SystemInformationDto systemInformationDto = systemInformationServiceFacade.getSystemInformation(context, locale);
    Map<String, Object> model = new HashMap<String, Object>();
    model.put("request", request);
    model.put("systemInformationDto", systemInformationDto);
    Map<String, Object> status = new HashMap<String, Object>();
    List<String> errorMessages = new ArrayList<String>();
    status.put("errorMessages", errorMessages);
    ModelAndView modelAndView = new ModelAndView("systemInformation", "model", model);
    modelAndView.addObject("status", status);
    return modelAndView;
}
Also used : Locale(java.util.Locale) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ModelAndView(org.springframework.web.servlet.ModelAndView) ServletContext(javax.servlet.ServletContext) RequestContext(org.springframework.web.servlet.support.RequestContext) SystemInformationDto(org.mifos.application.admin.servicefacade.SystemInformationDto) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 2 with RequestContext

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

the class TilesView method renderMergedOutputModel.

@Override
protected void renderMergedOutputModel(Map<String, Object> model, HttpServletRequest request, HttpServletResponse response) throws Exception {
    exposeModelAsRequestAttributes(model, request);
    if (this.exposeJstlAttributes) {
        JstlUtils.exposeLocalizationContext(new RequestContext(request, getServletContext()));
    }
    if (this.alwaysInclude) {
        request.setAttribute(AbstractRequest.FORCE_INCLUDE_ATTRIBUTE_NAME, true);
    }
    Request tilesRequest = createTilesRequest(request, response);
    this.renderer.render(getUrl(), tilesRequest);
}
Also used : AbstractRequest(org.apache.tiles.request.AbstractRequest) ServletRequest(org.apache.tiles.request.servlet.ServletRequest) HttpServletRequest(javax.servlet.http.HttpServletRequest) Request(org.apache.tiles.request.Request) RequestContext(org.springframework.web.servlet.support.RequestContext)

Example 3 with RequestContext

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

the class ThemeTagTests method requestContext.

@Test
@SuppressWarnings("rawtypes")
public void requestContext() throws ServletException {
    PageContext pc = createPageContext();
    RequestContext rc = new RequestContext((HttpServletRequest) pc.getRequest());
    assertEquals("theme test message", rc.getThemeMessage("themetest"));
    assertEquals("theme test message", rc.getThemeMessage("themetest", (String[]) null));
    assertEquals("theme test message", rc.getThemeMessage("themetest", "default"));
    assertEquals("theme test message", rc.getThemeMessage("themetest", (Object[]) null, "default"));
    assertEquals("theme test message arg1", rc.getThemeMessage("themetestArgs", new String[] { "arg1" }));
    assertEquals("theme test message arg1", rc.getThemeMessage("themetestArgs", Arrays.asList(new String[] { "arg1" })));
    assertEquals("default", rc.getThemeMessage("themetesta", "default"));
    assertEquals("default", rc.getThemeMessage("themetesta", (List) null, "default"));
    MessageSourceResolvable resolvable = new DefaultMessageSourceResolvable(new String[] { "themetest" });
    assertEquals("theme test message", rc.getThemeMessage(resolvable));
}
Also used : DefaultMessageSourceResolvable(org.springframework.context.support.DefaultMessageSourceResolvable) MessageSourceResolvable(org.springframework.context.MessageSourceResolvable) DefaultMessageSourceResolvable(org.springframework.context.support.DefaultMessageSourceResolvable) PageContext(javax.servlet.jsp.PageContext) List(java.util.List) RequestContext(org.springframework.web.servlet.support.RequestContext) Test(org.junit.Test)

Example 4 with RequestContext

use of org.springframework.web.servlet.support.RequestContext 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 5 with RequestContext

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

the class ErrorsTagTests method exposeBindingResult.

@Override
protected void exposeBindingResult(Errors errors) {
    // wrap errors in a Model
    Map model = new HashMap();
    model.put(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 : HashMap(java.util.HashMap) MockPageContext(org.springframework.mock.web.test.MockPageContext) RequestContext(org.springframework.web.servlet.support.RequestContext) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

RequestContext (org.springframework.web.servlet.support.RequestContext)13 HashMap (java.util.HashMap)5 Map (java.util.Map)4 MockPageContext (org.springframework.mock.web.test.MockPageContext)4 Test (org.junit.Test)3 List (java.util.List)2 HttpServletRequest (javax.servlet.http.HttpServletRequest)2 HttpServletResponse (javax.servlet.http.HttpServletResponse)2 PageContext (javax.servlet.jsp.PageContext)2 MessageSourceResolvable (org.springframework.context.MessageSourceResolvable)2 DefaultMessageSourceResolvable (org.springframework.context.support.DefaultMessageSourceResolvable)2 MockHttpServletRequest (org.springframework.mock.web.test.MockHttpServletRequest)2 MockHttpServletResponse (org.springframework.mock.web.test.MockHttpServletResponse)2 TestBean (org.springframework.tests.sample.beans.TestBean)2 StaticWebApplicationContext (org.springframework.web.context.support.StaticWebApplicationContext)2 JspAwareRequestContext (org.springframework.web.servlet.support.JspAwareRequestContext)2 JsonView (com.thoughtworks.go.server.web.JsonView)1 SimpleHash (freemarker.template.SimpleHash)1 Template (freemarker.template.Template)1 ArrayList (java.util.ArrayList)1