Spring Framework RequestContext - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Spring Framework RequestContext class.

This code example shows how to use the following methods:getLocale, getMessageSource, getTimeZone, getRequest, getServletContext
 
	/** 
	 * Create a new JstlView with the given URL. 
	 * @param url the URL to forward to 
	 * @param messageSource the MessageSource to expose to JSTL tags 
	 * (will be wrapped with a JSTL-aware MessageSource that is aware of JSTL's 
	 * {@code javax.servlet.jsp.jstl.fmt.localizationContext} context-param) 
	 * @see JstlUtils#getJstlAwareMessageSource 
	 */ 
	public JstlView(String url, MessageSource messageSource) { 
		this(url); 
		this.messageSource = messageSource; 
	} 
 
 
	/** 
	 * Wraps the MessageSource with a JSTL-aware MessageSource that is aware 
	 * of JSTL's {@code javax.servlet.jsp.jstl.fmt.localizationContext} 
	 * context-param. 
	 * @see JstlUtils#getJstlAwareMessageSource 

8
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getContextPath, getLocale, getPathToServlet, getQueryString, getRequestUri
    @Inject 
    private ServletContext servletContext; 
 
    @Override 
    public void resolveData(final HttpServletRequest request, final HttpServletResponse response, final Map<String, ? extends Object> model, final SoyMapData root) { 
        final RequestContext requestContext = new RequestContext(request, response, servletContext, (Map<String, Object>) model); 
 
        if (requestContext.getContextPath() != null) { 
            root.put(prefix + "contextPath", requestContext.getContextPath()); 
        } 
        if (requestContext.getPathToServlet() != null) { 
            root.put(prefix + "pathToServlet", requestContext.getPathToServlet()); 
        } 
        if (requestContext.getQueryString() != null) { 
            root.put(prefix + "queryString", requestContext.getQueryString()); 
        } 
        if (requestContext.getRequestUri() != null) { 
            root.put(prefix + "requestUri", requestContext.getRequestUri()); 
        } 
        if (requestContext.getLocale() != null) { 

6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getLocale
 
    @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; 
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getMessage
     * @param arguments 
     * @return 
     */ 
    public static String getMessage(HttpServletRequest request, String key, 
            String defaultMsg, Object[] arguments) { 
        RequestContext ctx = new RequestContext(request); 
        return ctx.getMessage(key, arguments, defaultMsg); 
    } 
 
    public static String getClientIpAddr(HttpServletRequest request) { 
        String ip = request.getHeader("X-Forwarded-For"); 
        if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { 
            ip = request.getHeader("Proxy-Client-IP"); 
        } 
        if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { 
            ip = request.getHeader("WL-Proxy-Client-IP"); 
        } 
        if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { 
            ip = request.getHeader("HTTP_CLIENT_IP"); 
        } 
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
			mergedModel.putAll(model); 
		} 
 
		// Expose RequestContext? 
		if (this.requestContextAttribute != null) { 
			mergedModel.put(this.requestContextAttribute, createRequestContext(request, response, mergedModel)); 
		} 
 
		return mergedModel; 
	} 
 
	/** 
	 * Create a RequestContext to expose under the specified attribute name. 
	 * <p>Default implementation creates a standard RequestContext instance for the 
	 * given request and model. Can be overridden in subclasses for custom instances. 
	 * @param request current HTTP request 
	 * @param model combined output Map (never {@code null}), 
	 * with dynamic values taking precedence over static attributes 
	 * @return the RequestContext instance 
	 * @see #setRequestContextAttribute 

5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getLocale, getMessageSource, getTimeZone
	 * @see net.sf.jasperreports.engine.JRParameter#REPORT_LOCALE 
	 * @see net.sf.jasperreports.engine.JRParameter#REPORT_RESOURCE_BUNDLE 
	 * @see org.springframework.web.servlet.support.JstlUtils#exposeLocalizationContext 
	 */ 
	protected void exposeLocalizationContext(Map<String, Object> model, HttpServletRequest request) { 
		RequestContext rc = new RequestContext(request, getServletContext()); 
		Locale locale = rc.getLocale(); 
		if (!model.containsKey(JRParameter.REPORT_LOCALE)) { 
			model.put(JRParameter.REPORT_LOCALE, locale); 
		} 
		TimeZone timeZone = rc.getTimeZone(); 
		if (timeZone != null && !model.containsKey(JRParameter.REPORT_TIME_ZONE)) { 
			model.put(JRParameter.REPORT_TIME_ZONE, timeZone); 
		} 
		JasperReport report = getReport(); 
		if ((report == null || report.getResourceBundle() == null) && 
				!model.containsKey(JRParameter.REPORT_RESOURCE_BUNDLE)) { 
			model.put(JRParameter.REPORT_RESOURCE_BUNDLE, 
					new MessageSourceResourceBundle(rc.getMessageSource(), locale)); 
		} 

5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getRequestDataValueProcessor
	 */ 
	protected StringBuilder replaceUriTemplateVariables( 
			String targetUrl, Map<String, Object> model, Map<String, String> currentUriVariables, String encodingScheme) 
			throws UnsupportedEncodingException { 
 
		StringBuilder result = new StringBuilder(); 
		Matcher matcher = URI_TEMPLATE_VARIABLE_PATTERN.matcher(targetUrl); 
		int endLastMatch = 0; 
		while (matcher.find()) { 
			String name = matcher.group(1); 
			Object value = (model.containsKey(name) ? model.remove(name) : currentUriVariables.get(name)); 
			if (value == null) { 
				throw new IllegalArgumentException("Model has no value for key '" + name + "'"); 
			} 
			result.append(targetUrl.substring(endLastMatch, matcher.start())); 
			result.append(UriUtils.encodePathSegment(value.toString(), encodingScheme)); 
			endLastMatch = matcher.end(); 
		} 
		result.append(targetUrl.substring(endLastMatch, targetUrl.length())); 
		return result; 

4
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getBindStatus
		return command;
	} 
	 
	private BindStatus getStatus(String path, RequestContext requestContext) {
		if (requestContext != null) {
			return requestContext.getBindStatus(path);
		} 
		return null; 
	} 
	 
	private BindStatus getFieldStatus(String field) {
		if (this.command != null) {
			return getStatus(this.command + '.' + field, this.requestContext);
		} 
		return null; 
	} 
 
	private Errors getErrors() {
		if (this.command != null) {
			return getErrors(this.command, this.requestContext);
4
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getWebApplicationContext
 
    /** 
     * Use the application context itself for default message resolution. 
     */ 
    private MessageSource getMessageSource() { 
        return requestContext.getWebApplicationContext(); 
    } 
} 
4
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getMessage
    protected String defaultMessage(String code) {
        return "?" + code + "?";
    } 
 
    protected String getMessage(String code, List args, String defaultMessage) {
        return context.getMessage(code, args, defaultMessage);
    } 
} 
4
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
See Code Examples for Spring Framework RequestContext Methods: