alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Spring Framework example source code file (FacesWebRequest.java)

This example Spring Framework source code file (FacesWebRequest.java) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - Spring Framework tags/keywords

externalcontext, facesrequestattributes, faceswebrequest, faceswebrequest, locale, map, nativewebrequest, object, object, principal, security, string, string, stringbuffer, stringbuffer, util

The Spring Framework FacesWebRequest.java source code

/*
 * Copyright 2002-2008 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.springframework.web.context.request;

import java.security.Principal;
import java.util.Locale;
import java.util.Map;

import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;

import org.springframework.util.StringUtils;

/**
 * {@link WebRequest} adapter for a JSF {@link javax.faces.context.FacesContext}.
 *
 * @author Juergen Hoeller
 * @since 2.5.2
 */
public class FacesWebRequest extends FacesRequestAttributes implements NativeWebRequest {

	/**
	 * Create a new FacesWebRequest adapter for the given FacesContext.
	 * @param facesContext the current FacesContext
	 * @see javax.faces.context.FacesContext#getCurrentInstance()
	 */
	public FacesWebRequest(FacesContext facesContext) {
		super(facesContext);
	}


	public Object getNativeRequest() {
		return getExternalContext().getRequest();
	}

	public Object getNativeResponse() {
		return getExternalContext().getResponse();
	}


	public String getParameter(String paramName) {
		return (String) getExternalContext().getRequestParameterMap().get(paramName);
	}

	public String[] getParameterValues(String paramName) {
		return (String[]) getExternalContext().getRequestParameterMap().get(paramName);
	}

	public Map getParameterMap() {
		return getExternalContext().getRequestParameterMap();
	}

	public Locale getLocale() {
		return getFacesContext().getExternalContext().getRequestLocale();
	}

	public String getContextPath() {
		return getFacesContext().getExternalContext().getRequestContextPath();
	}

	public String getRemoteUser() {
		return getFacesContext().getExternalContext().getRemoteUser();
	}

	public Principal getUserPrincipal() {
		return getFacesContext().getExternalContext().getUserPrincipal();
	}

	public boolean isUserInRole(String role) {
		return getFacesContext().getExternalContext().isUserInRole(role);
	}

	public boolean isSecure() {
		return false;
	}

	public boolean checkNotModified(long lastModifiedTimestamp) {
		return false;
	}


	public String getDescription(boolean includeClientInfo) {
		ExternalContext externalContext = getExternalContext();
		StringBuffer buffer = new StringBuffer();
		buffer.append("context=").append(externalContext.getRequestContextPath());
		if (includeClientInfo) {
			Object session = externalContext.getSession(false);
			if (session != null) {
				buffer.append(";session=").append(getSessionId());
			}
			String user = externalContext.getRemoteUser();
			if (StringUtils.hasLength(user)) {
				buffer.append(";user=").append(user);
			}
		}
		return buffer.toString();
	}

	public String toString() {
		return "FacesWebRequest: " + getDescription(true);
	}

}

Other Spring Framework examples (source code examples)

Here is a short list of links related to this Spring Framework FacesWebRequest.java source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.