本文整理汇总了Java中javax.faces.context.FacesContext.getExternalContext方法的典型用法代码示例。如果您正苦于以下问题:Java FacesContext.getExternalContext方法的具体用法?Java FacesContext.getExternalContext怎么用?Java FacesContext.getExternalContext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.faces.context.FacesContext
的用法示例。
在下文中一共展示了FacesContext.getExternalContext方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: encodeAllAsElement
import javax.faces.context.FacesContext; //导入方法依赖的package包/类
@Override
protected void encodeAllAsElement(
FacesContext context,
RenderingContext rc,
UIComponent component,
FacesBean bean
) throws IOException
{
// call super...
super.encodeAllAsElement(context, rc, component, bean);
// now evaluate the EL
// We need to evaluate it here and store it on the sessionMap because
// during UploadedFileProcessor.processFile() there is no FacesContext
RequestContext requestContext = RequestContext.getCurrentInstance();
Object maxMemory = requestContext.getUploadedFileMaxMemory();
Object maxDiskSpace = requestContext.getUploadedFileMaxDiskSpace();
Object tempDir = requestContext.getUploadedFileTempDir();
ExternalContext external = context.getExternalContext();
Map<String, Object> sessionMap = external.getSessionMap();
sessionMap.put(UploadedFileProcessor.MAX_MEMORY_PARAM_NAME, maxMemory);
sessionMap.put(UploadedFileProcessor.MAX_DISK_SPACE_PARAM_NAME, maxDiskSpace);
sessionMap.put(UploadedFileProcessor.TEMP_DIR_PARAM_NAME, tempDir);
}
示例2: getSkin
import javax.faces.context.FacesContext; //导入方法依赖的package包/类
/**
* given the skinId, pass back the Skin.
*
* @param context FacesContext. If not available, pass in null.
* @param skinId
* @return Skin that is in this SkinFactory and has the skinId.
* @deprecated use SkinProvider to query skins
*/
@Deprecated
@Override
public Skin getSkin(FacesContext context, String skinId)
{
context = SkinUtils.getNonNullFacesContext(context);
if (skinId == null)
{
_LOG.warning("CANNOT_GET_SKIN_WITH_NULL_SKINID");
return null;
}
ExternalContext ec = context.getExternalContext();
SkinMetadata skinMetadata = new SkinMetadata.Builder().id(skinId).build();
return SkinProvider.getCurrentInstance(ec).getSkin(ec, skinMetadata);
}
示例3: getContentHandlerMap
import javax.faces.context.FacesContext; //导入方法依赖的package包/类
/**
* Returns the map of content handlers
* which hold the state of one XML tree.
* @param scopeMap
* @return
*/
protected Map<Object, List<MenuContentHandler> > getContentHandlerMap()
{
FacesContext facesContext = FacesContext.getCurrentInstance();
ExternalContext externalContext = facesContext.getExternalContext();
Map<String, Object> scopeMap =
externalContext.getApplicationMap();
Object lock = externalContext.getContext();
// cannot use double checked lock here as
// we cannot mark the reference as volatile
// therefore any reads should happen inside
// a synchronized block.
synchronized (lock)
{
TransientHolder<Map<Object, List<MenuContentHandler> >> holder =
(TransientHolder<Map<Object, List<MenuContentHandler> >>) scopeMap.get(_CACHED_MODELS_KEY);
Map<Object, List<MenuContentHandler>> contentHandlerMap = (holder != null) ? holder.getValue() : null;
if (contentHandlerMap == null)
{
contentHandlerMap =
new ConcurrentHashMap<Object, List<MenuContentHandler>>();
scopeMap.put(_CACHED_MODELS_KEY, TransientHolder.newTransientHolder( contentHandlerMap) );
scopeMap.put(_CACHED_MODELS_ID_CNTR_KEY,new AtomicInteger(-1));
}
return contentHandlerMap;
}
}
示例4: skipValidation
import javax.faces.context.FacesContext; //导入方法依赖的package包/类
public static boolean skipValidation(final FacesContext context) {
final ExternalContext externalContext = context.getExternalContext();
final Object validate = externalContext.getRequestMap().get(GetParamNames.VALIDATE.toString());
if (validate != null) {
return !(Boolean) validate;
}
Iterator<Entry<String, String[]>> parameterValuesIt = externalContext.getRequestParameterValuesMap()
.entrySet().iterator();
while (parameterValuesIt.hasNext()) {
Entry<String, String[]> parameterValues = parameterValuesIt.next();
final String key = parameterValues.getKey();
Iterator<String> idPrefixIt = VALIDATION_REQUIRED_COMPONENT_ID_PREFIXES.iterator();
while (idPrefixIt.hasNext()) {
String idPrefix = idPrefixIt.next();
if (key.contains(idPrefix)) {
externalContext.getRequestMap().put(GetParamNames.VALIDATE.toString(), Boolean.TRUE);
return false;
}
}
}
externalContext.getRequestMap().put(GetParamNames.VALIDATE.toString(), Boolean.FALSE);
return true;
}
示例5: shouldInterpretEmptyStringSubmittedValuesAsNull
import javax.faces.context.FacesContext; //导入方法依赖的package包/类
/**
* Checks if the <code>validate()</code> should interpret an empty
* submitted value should be handle as <code>NULL</code>
*
* @return a (cached) boolean to identify the interpretation as null
*/
public static boolean shouldInterpretEmptyStringSubmittedValuesAsNull(FacesContext context)
{
ExternalContext ec = context.getExternalContext();
Boolean interpretEmptyStringAsNull = (Boolean)ec.getApplicationMap().get(TRINIDAD_EMPTY_VALUES_AS_NULL_PARAM_NAME);
// not yet cached...
if (interpretEmptyStringAsNull == null)
{
// parses the web.xml to get the "javax.faces.INTERPRET_EMPTY_STRING_SUBMITTED_VALUES_AS_NULL" value
String param = ec.getInitParameter(JSF_SPEC_EMPTY_VALUES_AS_NULL_PARAM_NAME);
// evaluate the context parameter
interpretEmptyStringAsNull = "true".equalsIgnoreCase(param);
// cache the parsed value
ec.getApplicationMap().put(TRINIDAD_EMPTY_VALUES_AS_NULL_PARAM_NAME, interpretEmptyStringAsNull);
}
return interpretEmptyStringAsNull;
}
示例6: PartialViewContextImpl
import javax.faces.context.FacesContext; //导入方法依赖的package包/类
public PartialViewContextImpl(FacesContext context)
{
_context = context;
ExternalContext extContext = context.getExternalContext();
_requestType = ReqType.FULL;
if (_PARTIAL_AJAX.equals(extContext.getRequestHeaderMap().get(_FACES_REQUEST)))
{
// This request was sent with jsf.ajax.request()
if (extContext.getRequestParameterMap().get(_TRINIDAD_PPR) != null)
_requestType = ReqType.AJAX_LEGACY;
else
_requestType = ReqType.AJAX;
}
else if (CoreRenderKit.isLegacyPartialRequest(extContext))
{
_requestType = ReqType.LEGACY;
}
}
示例7: entrySelected
import javax.faces.context.FacesContext; //导入方法依赖的package包/类
public void entrySelected() {
FacesContext context = FacesContext.getCurrentInstance();
ExternalContext extContext = context.getExternalContext();
LandingpageEntryModel selectedEntry = findSelectedEntry(model
.getSelectedEntryKey());
try {
JSFUtils.redirect(extContext, selectedEntry.getRedirectUrl());
} catch (Exception e) {
extContext.log(getClass().getName() + ".startService()", e);
} finally {
// reset requested key;
model.setSelectedEntryKey(null);
model.setSelectedCategory(0);
}
}
示例8: _warnedClientIdCachingConfig
import javax.faces.context.FacesContext; //导入方法依赖的package包/类
private static boolean _warnedClientIdCachingConfig(FacesContext context)
{
ExternalContext external = context.getExternalContext();
Map<String, Object> appMap = external.getApplicationMap();
return Boolean.TRUE.equals(appMap.get(_WARNED_CLIENT_ID_CACHING_KEY));
}
示例9: _clientIdCachingConfigWarned
import javax.faces.context.FacesContext; //导入方法依赖的package包/类
private static void _clientIdCachingConfigWarned(FacesContext context)
{
ExternalContext external = context.getExternalContext();
Map<String, Object> appMap = external.getApplicationMap();
appMap.put(_WARNED_CLIENT_ID_CACHING_KEY, Boolean.TRUE);
}
示例10: shortCircuitRenderView
import javax.faces.context.FacesContext; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public boolean shortCircuitRenderView(
FacesContext context) throws IOException
{
ExternalContext ec = context.getExternalContext();
if (isPartialRequest(ec))
{
Map<String, Object> requestMap = ec.getRequestMap();
UIViewRoot originalRoot = (UIViewRoot) requestMap.get(
TrinidadPhaseListener.INITIAL_VIEW_ROOT_KEY);
// If we're doing a partial update, and the page has changed, switch to a
// full page context.
if (context.getViewRoot() != originalRoot)
{
ViewHandler vh = context.getApplication().getViewHandler();
String viewId = context.getViewRoot().getViewId();
String redirect = vh.getActionURL(context, viewId);
String encodedRedirect = ec.encodeActionURL(redirect);
ec.redirect(encodedRedirect);
if (_LOG.isFine())
{
_LOG.fine("Page navigation to {0} happened during a PPR request " +
"on {1}; Apache Trinidad is forcing a redirect.",
new String[]{viewId, originalRoot.getViewId()});
}
return true;
}
}
// =-=AEW We could look for PPR requests that have no
// requested partial targets, in particular requests
// that simply need to launch a dialog.
return false;
}
示例11: FacesURLEncoder
import javax.faces.context.FacesContext; //导入方法依赖的package包/类
/**
* @todo Does this ever need to be absolute?
*/
public FacesURLEncoder(FacesContext context)
{
_externalContext = context.getExternalContext();
String viewId = context.getViewRoot().getViewId();
_defaultURL =
context.getApplication().getViewHandler().getActionURL(context, viewId);
}
示例12: getSkin
import javax.faces.context.FacesContext; //导入方法依赖的package包/类
protected Skin getSkin(FacesContext context)
{
Skin skin = null;
ExternalContext externalContext = context.getExternalContext();
SkinProvider skinProvider = SkinProvider.getCurrentInstance(externalContext);
Object skinIdObj = externalContext.getRequestParameterMap().get("skinId");
if (skinIdObj != null)
skin = skinProvider.getSkin(externalContext, new SkinMetadata.Builder().id(skinIdObj.toString()).build());
return skin;
}
示例13: _getInternalView
import javax.faces.context.FacesContext; //导入方法依赖的package包/类
private InternalView _getInternalView(
FacesContext context,
String viewId)
{
Object cached = _internalViewCache.get(viewId);
if (cached != null)
{
return ((cached == _NOT_FOUND) ? null : (InternalView)cached);
}
InternalView internal = _internalViews.get(viewId);
if (internal == null)
{
// If we're using suffix-mapping, then any internal viewId will
// get affixed with ".jsp" or ".jspx"; try trimming that off
// if present
ExternalContext external = context.getExternalContext();
// Only bother when using suffix-mapping (path info will always
// be non-null for prefix-mapping)
if (external.getRequestPathInfo() == null)
{
String suffix = external.getInitParameter("javax.faces.DEFAULT_SUFFIX");
if (suffix == null)
suffix = ".jspx";
if (viewId.endsWith(suffix))
{
String viewIdWithoutSuffix = viewId.substring(
0, viewId.length() - suffix.length());
internal = _internalViews.get(viewIdWithoutSuffix);
}
}
}
_internalViewCache.put(viewId, (internal == null) ? _NOT_FOUND : internal);
return internal;
}
示例14: listarProvaAvaliador
import javax.faces.context.FacesContext; //导入方法依赖的package包/类
public void listarProvaAvaliador() {
zerarLista();
FacesContext fc = FacesContext.getCurrentInstance();
ExternalContext ec = fc.getExternalContext();
HttpSession session = (HttpSession) ec.getSession(false);
Usuario usuariologado=(Usuario)session.getAttribute("usuario");
if (parecerProvaFiltrada != null && !parecerProvaFiltrada.isEmpty()) {
list.addAll(dao.findByNameAvaliador(parecerProvaFiltrada,usuariologado));
} else {
list.addAll(dao.findAllAvaliador(usuariologado));
}
}
示例15: _isBeanValidationAvailable
import javax.faces.context.FacesContext; //导入方法依赖的package包/类
/**
* This boolean indicates if Bean Validation is present.
*
* @return a (cached) boolean to identify if bean validation is present
*/
private static boolean _isBeanValidationAvailable(FacesContext context)
{
ExternalContext ec = context.getExternalContext();
Boolean couldLoadBeanValidationAPI = (Boolean) ec.getApplicationMap().get(TRINIDAD_BEAN_VALIDATION_AVAILABLE);
// not yet cached...
if (couldLoadBeanValidationAPI == null)
{
try
{
couldLoadBeanValidationAPI = Boolean.valueOf(ClassLoaderUtils.loadClass("javax.validation.Validation") != null);
if (couldLoadBeanValidationAPI)
{
try
{
// Trial-error approach to check for Bean Validation impl existence.
Validation.buildDefaultValidatorFactory().getValidator();
}
catch (Exception validationException)
{
// From section 3.5.6.2 of the spec
// "If the BeanValidator is used an no ValidatorFactory can be retrieved, a FacesException is raised. "
// Only BeanValidator needs to throw a FacesException, in this case just log the message
// and behave as if bean validation is disabled
_LOG.warning("VALIDATOR_FACTORY_UNAVAILABLE", validationException.getMessage());
couldLoadBeanValidationAPI = Boolean.FALSE;
}
}
}
catch (ClassNotFoundException cnfe)
{
// SPEC section 3.5.6.2:
// if a Bean Validation provider is not present, bean validation is disabled
// TODO need a better warning (i18n) here, which has more information
_LOG.warning("A Bean Validation provider is not present, therefore bean validation is disabled");
couldLoadBeanValidationAPI = Boolean.FALSE;
}
// cache the parsed value
ec.getApplicationMap().put(TRINIDAD_BEAN_VALIDATION_AVAILABLE, couldLoadBeanValidationAPI);
}
return couldLoadBeanValidationAPI;
}