@Override public ExternalContext getObject() { return FacesContext.getCurrentInstance().getExternalContext(); } @Override
@Override public FacesContext getObject() { return FacesContext.getCurrentInstance(); } @Override
@SuppressWarnings("unchecked") public static <T> T findBean(String beanName) { FacesContext context = FacesContext.getCurrentInstance(); return (T) context.getApplication().evaluateExpressionGet(context, "#{" + beanName + "}", Object.class); }
@Override public String getContextPath() { return getFacesContext().getExternalContext().getRequestContextPath(); }
@Override public Locale getLocale() { return getFacesContext().getExternalContext().getRequestLocale(); }
@Override public boolean isUserInRole(String role) { return getFacesContext().getExternalContext().isUserInRole(role); }
@Override @Nullable public Principal getUserPrincipal() { return getFacesContext().getExternalContext().getUserPrincipal(); }
@Override @Nullable public String getRemoteUser() { return getFacesContext().getExternalContext().getRemoteUser(); }
/** * Return the JSF ExternalContext that this adapter operates on. * @see javax.faces.context.FacesContext#getExternalContext() */ protected final ExternalContext getExternalContext() { return getFacesContext().getExternalContext(); }
/** * Return the JSF attribute Map for the specified scope. * @param scope constant indicating request or session scope * @return the Map representation of the attributes in the specified scope * @see #SCOPE_REQUEST * @see #SCOPE_SESSION */ protected Map<String, Object> getAttributeMap(int scope) { if (scope == SCOPE_REQUEST) { return getExternalContext().getRequestMap(); } else { return getExternalContext().getSessionMap(); } }
@Override public Object getSessionMutex() { // Enforce presence of a session first to allow listeners to create the mutex attribute ExternalContext externalContext = getExternalContext(); Object session = externalContext.getSession(true); Object mutex = externalContext.getSessionMap().get(WebUtils.SESSION_MUTEX_ATTRIBUTE); if (mutex == null) { mutex = (session != null ? session : externalContext); } return mutex; }
@Override public Object getNativeRequest() { return getExternalContext().getRequest(); }
@Override public Object getNativeResponse() { return getExternalContext().getResponse(); }
@Override public Map<String, String[]> getParameterMap() { return getExternalContext().getRequestParameterValuesMap(); }
@Override public Iterator<String> getParameterNames() { return getExternalContext().getRequestParameterNames(); }
@Override public ExternalContext getObject() { return FacesContext.getCurrentInstance().getExternalContext(); } @Override
/** * Retrieve the web application context to delegate bean name resolution to. * <p>The default implementation delegates to FacesContextUtils. * @param elContext the current JSF ELContext * @return the Spring web application context (never {@code null}) * @see org.springframework.web.jsf.FacesContextUtils#getRequiredWebApplicationContext */ protected WebApplicationContext getWebApplicationContext(ELContext elContext) { FacesContext facesContext = FacesContext.getCurrentInstance(); return FacesContextUtils.getRequiredWebApplicationContext(facesContext); }
FacesContext context = FacesContext.getCurrentInstance(); Bean bean = context.getApplication().evaluateExpressionGet(context, "#{beanName}", Bean.class);
@Nullable public static RequestAttributes getFacesRequestAttributes() { FacesContext facesContext = FacesContext.getCurrentInstance(); return (facesContext != null ? new FacesRequestAttributes(facesContext) : null); } }
/** * Retrieve the {@link WebApplicationContext} reference to expose. * <p>The default implementation delegates to {@link FacesContextUtils}, * returning {@code null} if no {@code WebApplicationContext} found. * @param elContext the current JSF ELContext * @return the Spring web application context * @see org.springframework.web.jsf.FacesContextUtils#getWebApplicationContext */ @Nullable protected WebApplicationContext getWebApplicationContext(ELContext elContext) { FacesContext facesContext = FacesContext.getCurrentInstance(); return FacesContextUtils.getRequiredWebApplicationContext(facesContext); }