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;
}
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);
}
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));
}
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;
}
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);
}
Aggregations