Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright 2004-2012 ICEsoft Technologies Canada Corp.
   *
   * 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.icefaces.util;
 
 
 import java.util.Map;
 
 public class EnvUtils {
 
     private static Logger log = Logger.getLogger(EnvUtils.class.getName());
 
     //The key used to store the current configuration in the application map.
     public static String ICEFACES_ENV_CONFIG = "org.icefaces.env.config";
 
     //Parameters configurable using context parameters
     public static String ICEFACES_AUTO = "org.icefaces.render.auto";
     public static String ICEFACES_AUTOID = "org.icefaces.autoid";
     public static String COMPRESS_DOM = "org.icefaces.compressDOM";
     public static String COMPRESS_RESOURCES = "org.icefaces.compressResources";
     public static String DELTA_SUBMT = "org.icefaces.deltaSubmit";
     public static String DIFF_CONFIG = "org.icefaces.diffConfig";
     public static String LAZY_PUSH = "org.icefaces.lazyPush";
     public static String STANDARD_FORM_SERIALIZATION = "org.icefaces.standardFormSerialization";
     public static String STRICT_SESSION_TIMEOUT = "org.icefaces.strictSessionTimeout";
     public static String SUBTREE_DIFF = "org.icefaces.subtreeDiff";
     public static String WINDOW_SCOPE_EXPIRATION = "org.icefaces.windowScopeExpiration";
     public static String MANDATORY_RESOURCE_CONFIG = "org.icefaces.mandatoryResourceConfiguration";
     public static String UNIQUE_RESOURCE_URLS = "org.icefaces.uniqueResourceURLs";
     public static String LAZY_WINDOW_SCOPE = "org.icefaces.lazyWindowScope";
     public static String DISABLE_DEFAULT_ERROR_POPUPS = "org.icefaces.disableDefaultErrorPopups";
     public static String FAST_BUSY_INDICATOR = "org.icefaces.fastBusyIndicator";
     public static String REPLAY_NAVIGATION_ON_RELOAD = "org.icefaces.replayNavigationOnReload";
     public static String GENERATE_HEAD_UPDATE = "org.icefaces.generateHeadUpdate";
     public static String INCLUDE_SCROLL_OFFSETS = "org.icefaces.includeScrollOffsets";
 
 
     //Parameters configurable using context parameters but only in compatibility mode
     public static String CONNECTION_LOST_REDIRECT_URI = "org.icefaces.connectionLostRedirectURI";
     public static String SESSION_EXPIRED_REDIRECT_URI = "org.icefaces.sessionExpiredRedirectURI";
 
     //Parameters configurable on a per page-basis as attributes of <ice:config/>
     public static String ICEFACES_RENDER = "org.icefaces.render";
     public static String ARIA_ENABLED = "org.icefaces.aria.enabled";
     public static String BLOCK_UI_ON_SUBMIT = "org.icefaces.blockUIOnSubmit";
     public static String MESSAGE_PERSISTENCE = "org.icefaces.messagePersistence";
 
     //Other parameters used internally by ICEfaces framework.
     public static final String HEAD_DETECTED = "org.icefaces.headDetected";
     public static final String BODY_DETECTED = "org.icefaces.bodyDetected";
     private static String RESOURCE_PREFIX = "/javax.faces.resource/";
     private static String PATH_TEMPLATE = "org.icefaces.resource.pathTemplate";
     private static String DUMMY_RESOURCE = "bridge.js";
     private static String USER_AGENT_COOKIE = "com.icesoft.user-agent";
     private static String HYPERBROWSER = "HyperBrowser";
     private static String[] DEFAULT_TEMPLATE = new String[]{".jsf"};
 
     //Use reflection to identify the JSF implementation.
     private static boolean isImplTested = false;
 
     private static boolean isMojarra = false;
     private static final String MOJARRA_STATE_SAVING_MARKER = "~com.sun.faces.saveStateFieldMarker~";
 
 
     private static boolean isMyFaces = false;
     private static final String MYFACES_STATE_SAVING_MARKER = "~org.apache.myfaces.saveStateFieldMarker~";
 
     private static String stateMarker;
 
     //Use reflection to identify if the Portlet classes are available.
    private static Class PortletSessionClass;
    private static Class PortletRequestClass;
    private static Class PortletResponseClass;
    static {
        try {
             = Class.forName("javax.portlet.PortletSession");
             = Class.forName("javax.portlet.PortletRequest");
             = Class.forName("javax.portlet.PortletResponse");
        } catch (Throwable t) {
            .log(."Portlet classes not available: "t);
        }
    }
    //Use reflection to identify if a Liferay specific class is available.
    private static Class LiferayClass;
    static {
        try {
             = Class.forName("com.liferay.portal.theme.ThemeDisplay");
        } catch (Throwable t) {
            .log(."Liferay class not available: "t);
        }
    }
    //Use reflection to identify if a WebSphere Portal specific class is available.
    private static Class WebSpherePortalClass;
    static {
        try {
             = Class.forName("com.ibm.ws.portletcontainer.PortletContainer");
        } catch (Throwable t) {
            .log(."WebSphere Portal class not available: "t);
        }
    }
    //Use reflection to identify if ICEpush is available.
    private static boolean icepushPresent;
    static {
        try {
            Class.forName("org.icepush.PushContext");
             = true;
        } catch (ClassNotFoundException e) {
             = false;
        }
    }


    
Returns the value of the context parameter org.icefaces.aria.enabled. The default value is true and indicates that views are ARIA (Accessible Rich Internet Applications) enabled. This context parameter is application-wide and works together with the 'ariaEnabled' attribute of the ICEfaces configuration tag <ice:config> so that ARIA support can be turned on and off selectively on a per page basis.

Parameters:
facesContext The current FacesContext instance used to access the application map.
Returns:
Returns the current setting of org.icefaces.aria.enabled. The default is true.
    public static boolean isAriaEnabled(FacesContext facesContext) {
        Object ariaEnabled = getViewParam(facesContext);
        if (null == ariaEnabled) {
            return EnvConfig.getEnvConfig(facesContext).;
        }
        return (..equals(ariaEnabled));
    }

    
Returns the value of the context parameter org.icefaces.autoid. The default value is true and indicates that the majority of standard JSF components will write their ids to the page markup. This allows page updates to be targetted as granularly as possible.

Parameters:
facesContext The current FacesContext instance used to access the application map.
Returns:
Returns the current setting of org.icefaces.autoid. The default is true.
    public static boolean isAutoId(FacesContext facesContext) {
        return EnvConfig.getEnvConfig(facesContext).;
    }

    
Returns the value of the context parameter org.icefaces.render.auto. The default value is true and indicates that DOM changes will automatically be applied to each page. This context parameter is application-wide and works together with the render attribute of the ICEfaces configuration tag <ice:config> so that DOM updates can be turned on and off selectively on a per page basis.

Parameters:
facesContext The current FacesContext instance used to access the application map.
Returns:
Returns the current setting of org.icefaces.render.auto. The default is true.
    public static boolean isAutoRender(FacesContext facesContext) {
        return EnvConfig.getEnvConfig(facesContext).;
    }

    
Returns the value of the context parameter org.icefaces.blockUIOnSubmit. The default value is false and indicates that the UI will not be blocked after a request has been submitted. To help deal with the problems with double-submits, this parameter can be set to true.

Parameters:
facesContext The current FacesContext instance used to access the application map.
Returns:
Returns the current setting of org.icefaces.blockUIOnSubmit. The default is false.
    public static boolean isBlockUIOnSubmit(FacesContext facesContext) {
        Object blockUIOnSubmit = getViewParam(facesContext);
        if (null == blockUIOnSubmit) {
            return EnvConfig.getEnvConfig(facesContext).;
        }
        return (..equals(blockUIOnSubmit));
    }

    
Programmatically override the value of blockUIOnSubmit.

Parameters:
facesContext The current FacesContext instance used to access the application map.
value
    public static void setBlockUIOnSubmit(FacesContext facesContextboolean value) {
        setViewParam(facesContextvalue);
    }

    
Returns the value of the context parameter org.icefaces.compressDOM. The default value is false and indicates that, between requests, the server-side DOM will be serialized and compressed to save memory.

Parameters:
facesContext The current FacesContext instance used to access the application map.
Returns:
Returns the current setting of org.icefaces.compressDOM. The default is false.
    public static boolean isCompressDOM(FacesContext facesContext) {
        //consider making this a per-view setting
        return EnvConfig.getEnvConfig(facesContext).;
    }

    
Returns the value of the context parameter org.icefaces.compressResources. The default value is true and indicates that, for resource requests, certain resources should be automatically compressed via gzip before being sent.

Parameters:
facesContext The current FacesContext instance used to access the application map.
Returns:
Returns the current setting of org.icefaces.compressResources. The default is true.
    public static boolean isCompressResources(FacesContext facesContext) {
        return EnvConfig.getEnvConfig(facesContext).;
    }

    
Returns the value of the context parameter org.icefaces.connectionLostRedirectURI. The default value is the String "null" and indicates that no URI has been set and the default behaviour is taken when the Ajax Push connection is lost. Setting a URI value tells ICEfaces to redirect to that view if the Ajax Push connection is lost.

Note: This value is only relevant when running ICEfaces 2+ with the compatible component suite:

Parameters:
facesContext The current FacesContext instance used to access the application map.
Returns:
Returns the current setting of org.icefaces.connectionLostRedirectURI. The default is the String "null".
    public static String getConnectionLostRedirectURI(FacesContext facesContext) {
        return EnvConfig.getEnvConfig(facesContext).;
    }

    
Returns the value for org.icefaces.diffConfig. This is configured as a space separated name=value string.

Parameters:
facesContext The current FacesContext instance used to access the application map.
Returns:
Returns the current setting of org.icefaces.diffConfig. The default is null.
    public static String getDiffConfig(FacesContext facesContext) {
        Object diffConfig = getViewParam(facesContext);
        if (null == diffConfig) {
            return EnvConfig.getEnvConfig(facesContext).;
        }
        return (StringdiffConfig;
    }

    
Returns the value of the context parameter org.icefaces.deltaSubmit. The default value is false and indicates that the delta submit features is not currently enabled. When delta submit is enabled, form submission is done in a way that minimizes what is sent across the wire.

Parameters:
facesContext The current FacesContext instance used to access the application map.
Returns:
Returns the current setting of org.icefaces.deltaSubmit. The default is false.
    public static boolean isDeltaSubmit(FacesContext facesContext) {
        return EnvConfig.getEnvConfig(facesContext).;
    }

    
Returns the value of the context parameter org.icefaces.lazyPush. The default value is true and indicates that ICEpush will be initially lazily. In other words, ICEpush will not activate and open a blocking connection until the first push request is made. By setting lazyPush to false, ICEpush will be automatically activated for each ICEfaces page.

This context parameter is application-wide and works together with the lazyPush attribute of the ICEfaces configuration tag <ice:config> so that ICEpush can be set to activate lazily on a per-page basis.

Parameters:
facesContext The current FacesContext instance used to access the application map.
Returns:
Returns the current setting of org.icefaces.lazyPush. The default is true.
    public static boolean isLazyPush(FacesContext facesContext) {
        Object lazyPush = getViewParam(facesContext);
        if (null == lazyPush) {
            return EnvConfig.getEnvConfig(facesContext).;
        }
        return (..equals(lazyPush));
    }


    
Returns true if Liferay classes are detected via reflection.

Returns:
Returns true if Liferay classes are detected via reflection.
    public static boolean isLiferay() {
        return  != null;
    }


    
Returns true if WebSphere Portal class is detected via reflection.

Returns:
Returns true if WebSphere Portal class is detected via reflection.
    public static boolean isWebSpherePortal() {
        return  != null;
    }


    
Returns true if JSF Partial State Saving is active.

Parameters:
facesContext The current FacesContext instance.
Returns:
Returns the current state of JSF Partial State Saving. The default is true.
    public static boolean isPartialStateSaving(FacesContext facesContext) {
        return !("false".equalsIgnoreCase(
                FacesContext.getCurrentInstance().getExternalContext()
                        .getInitParameter("javax.faces.PARTIAL_STATE_SAVING")));
    }

    
Returns the value of the context parameter org.icefaces.sessionExpiredRedirectURI. The default value is the String "null" and indicates that no URI has been set and the default behaviour is taken when the session expires. Setting a URI value tells ICEfaces to redirect to that view if the Ajax Push connection is lost.

Note: This value is only relevant when running ICEfaces 2+ with the compatible component suite:

Parameters:
facesContext The current FacesContext instance used to access the application map.
Returns:
Returns the current setting of org.icefaces.sessionExpiredRedirectURI. The default is the String "null".
    public static String getSessionExpiredRedirectURI(FacesContext facesContext) {
        return EnvConfig.getEnvConfig(facesContext).;
    }

    
Returns the value of the context parameter org.icefaces.standardFormSerialization. The default value is false and indicates that ICEfaces should do optimized for submission based on the submitting element. Setting this value to true indicates that ICEfaces should do a normal, full form submission.

Parameters:
facesContext The current FacesContext instance used to access the application map.
Returns:
Returns the current setting of org.icefaces.standardFormSerialization. The default is false.
    public static boolean isStandardFormSerialization(FacesContext facesContext) {
        return EnvConfig.getEnvConfig(facesContext).;
    }

    
Returns the value of the context parameter org.icefaces.strictSessionTimeout. The default value is false and indicates that ICEfaces should not interfere with container-managed session timeout. Setting this value to true indicates that ICEfaces should attempt to enforce the configured session timeout by ignoring intervening push activity. Only user events result in extending the session lifetime.

Parameters:
facesContext The current FacesContext instance used to access the application map.
Returns:
Returns the current setting of org.icefaces.strictSessionTimeout. The default is false.
    public static boolean isStrictSessionTimeout(FacesContext facesContext) {
        return EnvConfig.getEnvConfig(facesContext).;
    }

    
Returns the value of the context parameter org.icefaces.subtreeDiff. The default value is true and indicates that diffs will be calculated for subtree rendering.

Parameters:
facesContext The current FacesContext instance used to access the application map.
Returns:
Returns the current setting of org.icefaces.subtreeDiff. The default is true.
    public static boolean isSubtreeDiff(FacesContext facesContext) {
        Object subtreeDiff = getViewParam(facesContext);
        if (null == subtreeDiff) {
            return EnvConfig.getEnvConfig(facesContext).;
        }
        return (..equals(subtreeDiff));
    }

    
Returns the value of the context parameter org.icefaces.windowScopeExpiration. The default value is 1000 milliseconds and indicates the length of time window-scoped values remain valid in the session after a reload or redirect occurs. This allows for postbacks that might occur quickly after a reload or redirect to successfully retrieve the relevant window-scoped values.

Parameters:
facesContext The current FacesContext instance used to access the application map.
Returns:
Returns the current setting of org.icefaces.windowScopeExpiration. The default is 1000 milliseconds.
    public static long getWindowScopeExpiration(FacesContext facesContext) {
        return EnvConfig.getEnvConfig(facesContext).;
    }
    public static String getMandatoryResourceConfig(FacesContext facesContext) {
        String configValue = EnvConfig.getEnvConfig(facesContext)
                .;
        String result = configValue;
        String overValue = (StringgetViewParam(facesContext);
        if (null != overValue) {
            result = overValue;
        }
        if (null != result) {
            result = result.trim();
        }
        return result;
    }
    public static boolean isUniqueResourceURLs(FacesContext facesContext) {
        return EnvConfig.getEnvConfig(facesContext).;
    }
    public static void createSessionOnPageLoad(FacesContext context) {
        final ExternalContext externalContext = context.getExternalContext();
        //create session if non-ajax request
        externalContext.getSession(!context.getPartialViewContext().isAjaxRequest());
    }
    public static boolean isSessionInvalid(FacesContext context) {
        final ExternalContext externalContext = context.getExternalContext();
        //if session invalid or expired block other resource handlers from running
        return externalContext.getSession(false) == null;
    }

    
Returns true if the browser is enhanced with additional features.

Parameters:
facesContext The current FacesContext.
Returns:
true if browser is enhanced.
    public static boolean isEnhancedBrowser(FacesContext facesContext) {
        Cookie cookie = (CookiefacesContext.getExternalContext()
                .getRequestCookieMap().get();
        if (null != cookie) {
            return cookie.getValue().startsWith();
        }
        return false;
    }

    
Returns true if the browser is enhanced via auxiliary upload.

Parameters:
facesContext The current FacesContext.
Returns:
true if browser supports auxiliary upload.
    public static boolean isAuxUploadBrowser(FacesContext facesContext) {
        boolean isAux = facesContext.getExternalContext().getSessionMap()
                .containsKey(.);
        return isAux;
    }
    public static boolean isICEfacesView(FacesContext facesContext) {
        //Check to see if the view is configured to use ICEfaces (default is to enable ICEfaces).
        UIViewRoot viewRoot = facesContext.getViewRoot();
        Map viewMap = viewRoot.getViewMap();
        Object icefacesRender = viewMap.get();
        if (null == icefacesRender) {
            icefacesRender = EnvConfig.getEnvConfig(facesContext).;
            viewMap.put(icefacesRender);
        }
        //using .equals on Boolean to obtain boolean robustly
        return (..equals(icefacesRender));
    }
    public static boolean isICEpushPresent() {
        return ;
    }
    public static boolean hasHeadAndBodyComponents(FacesContext facesContext) {
        //ICE-5613: ICEfaces must have h:head and h:body tags to render resources into
        //Without these components, ICEfaces is disabled.
        UIViewRoot viewRoot = facesContext.getViewRoot();
        Map viewMap = viewRoot.getViewMap();
        if (!viewMap.containsKey() || !viewMap.containsKey()) {
            if (.isLoggable(.)) {
                .log(."ICEfaces disabled for view " + viewRoot.getViewId() +
                        "\n  h:head tag available: " + viewMap.containsKey() +
                        "\n  h:body tag available: " + viewMap.containsKey());
            }
            return false;
        }
        return true;
    }
    //remove this once multi-form ViewState is addressed
    public static boolean needViewStateHack() {
        return isMojarra();
    }
    public static String[] getPathTemplate() {
        FacesContext facesContext = FacesContext.getCurrentInstance();
        ExternalContext externalContext = facesContext.getExternalContext();
        boolean isPortlet = EnvUtils.instanceofPortletRequest(externalContext.getRequest());
        //ICE-8540
        //The optimization of storing the path template doesn't work well in portlets because
        //the path will include the host and port, which could change based on the URL used
        //by the client.  So we skip the optimization when using portlets.
        String[] pathTemplate = null;
        if( !isPortlet ){
            Map applicationMap = externalContext.getApplicationMap();
            pathTemplate = (String[]) applicationMap.get();
            if (null != pathTemplate) {
                return pathTemplate;
            }
        }
        Resource dummyResource = facesContext.getApplication()
                .getResourceHandler().createResource();
        if (null != dummyResource) {
            String dummyPath = dummyResource.getRequestPath();
            pathTemplate = extractPathTemplate(dummyPath);
        }
        if (null == pathTemplate) {
            return ;
        }
        if(!isPortlet){
            Map applicationMap = externalContext.getApplicationMap();
            applicationMap.put(pathTemplate);
        }
        return pathTemplate;
    }
    private static String[] extractPathTemplate(String path) {
        int start = path.indexOf();
        if (start < 0) {
            return null;
        }
        String pre = path.substring(0, start);
        String post = path.substring(start + .length());
        return new String[]{prepost};
    }
    public static boolean instanceofPortletSession(Object session) {
        return  != null && .isInstance(session);
    }
    public static boolean instanceofPortletRequest(Object request) {
        return  != null && .isInstance(request);
    }
    public static boolean instanceofPortletResponse(Object response) {
        return  != null && .isInstance(response);
    }
    public static HttpServletRequest getSafeRequest(FacesContext fc) {
        ExternalContext ec = fc.getExternalContext();
        Object rawReq = ec.getRequest();
        if (instanceofPortletRequest(rawReq)) {
            return new ProxyHttpServletRequest(fc);
        }
        return (HttpServletRequestrawReq;
    }
    public static HttpServletResponse getSafeResponse(FacesContext fc) {
        ExternalContext ec = fc.getExternalContext();
        Object rawRes = ec.getResponse();
        if (instanceofPortletResponse(rawRes)) {
            return new ProxyHttpServletResponse(fc);
        }
        return (HttpServletResponserawRes;
    }
    //Leave this for backwards compatibility that defaults to a PORTLET_APPLICATION scope.
    public static HttpSession getSafeSession(FacesContext fc) {
        return getSafeApplicationScopeSession(fc);
    }
    private static HttpSession getSafeSession(FacesContext fcint scope) {
        ExternalContext ec = fc.getExternalContext();
        Object rawSess = ec.getSession(true);
        if (instanceofPortletSession(rawSess)) {
            return new ProxySession(fcscope);
        }
        return (HttpSessionrawSess;
    }
    public static HttpSession getSafePortletScopeSession(FacesContext fc) {
        return getSafeSession(fc.);
    }
        return getSafeSession(fc.);
    }
    public static boolean isPushRequest(FacesContext facesContext) {
        ExternalContext ec = facesContext.getExternalContext();
        String reqPath = ec.getRequestServletPath();
        String pathInfo = ec.getRequestPathInfo();
        String reqParam = ec.getRequestParameterMap().get("ice.submit.type");
        if (reqPath != null && reqPath.contains(.) ||
                pathInfo != null && pathInfo.contains(.) ||
                "ice.push".equals(reqParam)) {
            return true;
        }
        return false;
    }
    public static boolean isLazyWindowScope(FacesContext facesContext) {
        return EnvConfig.getEnvConfig(facesContext).;
    }
    public static boolean disableDefaultErrorPopups(FacesContext facesContext) {
        Object disableDefaultErrorPopups = getViewParam(facesContext);
        if (null == disableDefaultErrorPopups) {
            return EnvConfig.getEnvConfig(facesContext).;
        }
        return (..equals(disableDefaultErrorPopups));
    }


    
Programmatically override the value of disableDefaultErrorPopups.

Parameters:
facesContext The current FacesContext instance used to access the application map.
value
    public static void setDisableDefaultErrorPopups(FacesContext facesContextboolean value) {
        setViewParam(facesContextvalue);
    }
    public static boolean isFastBusyIndicator(FacesContext facesContext) {
        return EnvConfig.getEnvConfig(facesContext).;
    }
    public static boolean isReplayNavigationOnReload(FacesContext facesContext) {
        return EnvConfig.getEnvConfig(facesContext).;
    }
    public static boolean isMessagePersistence(final FacesContext facesContext) {
        return EnvConfig.getEnvConfig(facesContext).;
    }
    public static boolean isMojarra() {
        testImpl();
        return ;
    }
    public static boolean isMyFaces() {
        testImpl();
        return ;
    }
    private static void testImpl() {
        if (!) {
            String implName = FacesContext.getCurrentInstance()
                    .getClass().getName();
            if (implName.startsWith("com.sun")) {
                 = true;
                 = true;
            } else if (implName.startsWith("org.apache")) {
                 = true;
                 = true;
            }
        }
    }
    public static String getStateMarker() {
        if ( == null) {
            if (EnvUtils.isMojarra()) {
                 = ;
            } else if (EnvUtils.isMyFaces()) {
                 = ;
            } else {
                .warning("could not determine JSF implementation");
            }
        }
        return ;
    }
    public static boolean containsBeans(Map<StringObjectscopeMap) {
        //skip the objects saved in the map by ICEfaces framework while testing for the existence of beans
        for (Map.Entry entry : scopeMap.entrySet()) {
            String key = (Stringentry.getKey();
            Object value = entry.getValue();
            if (!value.getClass().getName().startsWith("org.icefaces.impl") & !(
                    (value instanceof String) || (value instanceof Character) ||
                            (value instanceof Boolean) || (value instanceof Number))) {
                return true;
            }
        }
        return false;
    }
    public static boolean containsDisposedBeans(Map<StringObjectscopeMap) {
        //skip the objects saved in the map by ICEfaces framework while testing for the existence of beans
        for (Map.Entry entry : scopeMap.entrySet()) {
            String key = (Stringentry.getKey();
            Object value = entry.getValue();
            if (value.getClass().isAnnotationPresent(WindowDisposed.class)) {
                return true;
            }
        }
        return false;
    }
    //utility method to get per-view configuration values
    static Object getViewParam(FacesContext facesContextString name) {
        UIViewRoot viewRoot = facesContext.getViewRoot();
        if (null == viewRoot) {
            return null;
        }
        Map viewMap = viewRoot.getViewMap();
        return viewMap.get(name);
    }
    static void setViewParam(FacesContext facesContextString nameObject value) {
        UIViewRoot viewRoot = facesContext.getViewRoot();
        if (null != viewRoot) {
            viewRoot.getViewMap().put(namevalue);
        }
    }
    public static boolean generateHeadUpdate(FacesContext context) {
        return EnvConfig.getEnvConfig(context).;
    }
    public static boolean isIncludeScrollOffsets(FacesContext context) {
        return EnvConfig.getEnvConfig(context).;
    }
class EnvConfig {
    private static Logger log = Logger.getLogger(EnvConfig.class.getName());
    boolean autoRender;
    boolean autoId;
    boolean ariaEnabled;
    boolean blockUIOnSubmit;
    boolean compressDOM;
    boolean compressResources;
    boolean deltaSubmit;
    boolean lazyPush;
    boolean pushActive;
    boolean strictSessionTimeout;
    boolean subtreeDiff;
    boolean uniqueResourceURLs;
    boolean lazyWindowScope;
    boolean messagePersistence;
    public boolean disableDefaultErrorPopups;
    public boolean fastBusyIndicator;
    boolean replayNavigationOnReload;
    boolean generateHeadUpdate;
    public boolean includeScrollOffsets;
    public EnvConfig(Map initMap) {
        init(initMap);
    }
    public void init(Map initMap) {
        StringBuilder info = new StringBuilder();
         = decodeBoolean(initMap.trueinfo);
         = decodeBoolean(initMap.trueinfo);
         = decodeBoolean(initMap.trueinfo);
         = decodeBoolean(initMap.falseinfo);
         = decodeBoolean(initMap.falseinfo);
         = decodeBoolean(initMap.falseinfo);
         = decodeString(initMap.nullinfo);
         = decodeBoolean(initMap.falseinfo);
         = decodeBoolean(initMap.trueinfo);
         = decodeBoolean(initMap.falseinfo);
         = decodeBoolean(initMap.trueinfo);
         = decodeBoolean(initMap.falseinfo);
         = decodeBoolean(initMap.trueinfo);
         = decodeLong(initMap., 1000, info);
         = decodeString(initMap."none"info);
         = decodeBoolean(initMap.trueinfo);
         = decodeBoolean(initMap.trueinfo);
         = decodeBoolean(initMap.trueinfo);
         = decodeBoolean(initMap.falseinfo);
         = decodeBoolean(initMap.falseinfo);
        .info("ICEfaces Configuration: \n" + info);
    }
    public static EnvConfig getEnvConfig(FacesContext facesContext) {
        ExternalContext externalContext = facesContext.getExternalContext();
        Map appMap = externalContext.getApplicationMap();
        EnvConfig envConfig = (EnvConfigappMap.get(.);
        if (null == envConfig) {
            envConfig = new EnvConfig(externalContext.getInitParameterMap());
            appMap.put(.envConfig);
        }
        return envConfig;
    }
    boolean decodeBoolean(Map mapString nameboolean defaultValueStringBuilder info) {
        String paramValue = (Stringmap.get(name);
        if (null == paramValue) {
            info.append(name).append(": ").append(defaultValue).append(" [default]\n");
            return defaultValue;
        }
        if ("true".equalsIgnoreCase(paramValue)) {
            info.append(name).append(": true\n");
            return true;
        }
        if ("false".equalsIgnoreCase(paramValue)) {
            info.append(name).append(": false\n");
            return false;
        }
        info.append(name).append(": ").append(defaultValue).append(" [default replacing malformed non-boolean value: ").append(paramValue).append("]\n");
        return defaultValue;
    }
    String decodeString(Map mapString nameString defaultValueStringBuilder info) {
        String paramValue = (Stringmap.get(name);
        if (null == paramValue) {
            info.append(name).append(": ").append(defaultValue).append(" [default]\n");
            return defaultValue;
        }
        info.append(name).append(": ").append(paramValue).append("\n");
        return paramValue;
    }
    long decodeLong(Map mapString namelong defaultValueStringBuilder info) {
        String paramValue = (Stringmap.get(name);
        if (null == paramValue) {
            info.append(name).append(" = ").append(defaultValue).append(" [default]\n");
            return defaultValue;
        }
        try {
            return Long.parseLong(paramValue);
        } catch (Exception e) {
            info.append(name).append(": ").append(defaultValue).append(" [default replacing malformed long value: ").append(paramValue).append("]\n");
        }
        return defaultValue;
    }
New to GrepCode? Check out our FAQ X