Java Code Examples for javax.faces.context.FacesContext.isProjectStage()

The following are Jave code examples for showing how to use isProjectStage() of the javax.faces.context.FacesContext class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: myfaces-trinidad   File: RequestContextImpl.java   View Source Code Vote up 5 votes
@Override
public boolean isDebugOutput()
{
  // FALSE is the default value...
  boolean debugOutput = Boolean.TRUE.equals(
    _bean.getProperty(RequestContextBean.DEBUG_OUTPUT_KEY));

  FacesContext fc = FacesContext.getCurrentInstance();

  if (fc.isProjectStage(ProjectStage.Production))
  {
    // on production we always want FALSE, unless the
    // user explicitly set the config to TRUE, but
    // generate a WARNING message for that.
    if (debugOutput)
    {
       _LOG.warning("DEBUG_OUTPUT_TRUE_IN_PRODUCTION_STAGE");
      return true;
    }

    return false;
  }
  else
  {
    return debugOutput;
  }
}
 
Example 2
Project: myfaces-trinidad   File: UIXComponentBase.java   View Source Code Vote up 5 votes
private static void _warnClientIdCachingConfig(FacesContext context)
{
  if (_CLIENT_ID_CACHING != ClientIdCaching.ON &&
       context.isProjectStage(ProjectStage.Production) &&
       !_warnedClientIdCachingConfig(context))
  {
    _LOG.warning(
      "The org.apache.myfaces.trinidad.CLIENT_ID_CACHING system property is set to: " +
       _CLIENT_ID_CACHING +
      ".  For best performance, client id caching should be ON in production environments.");

    _clientIdCachingConfigWarned(context);
  }
}
 
Example 3
Project: myfaces-trinidad   File: LibraryScriptlet.java   View Source Code Vote up 4 votes
static private boolean _isDebug(FacesContext context)
{
  if (_debugJavascript == null)
  {
    String debugJavascript = context.
        getExternalContext().getInitParameter(_DEBUG_JAVASCRIPT);

    if (debugJavascript != null)
    {
      if (debugJavascript.equalsIgnoreCase("true"))
      {
        _debugJavascript = Boolean.TRUE;
      
        // if Apache MyFaces Trinidad is running in production stage
        // running with JavaScript debugging is not desired, therefore
        // we generate a WARNING message; otherwise we just inform the user
        if (context.isProjectStage(ProjectStage.Production))
        {
          _LOG.warning("RUNNING_DEBUG_JAVASCRIPT_IN_PRODUCTION_STAGE");
        }
        else
        {
          _LOG.info("RUNNING_DEBUG_JAVASCRIPT"); 
        }
      }
      else
      {
        _debugJavascript = Boolean.FALSE; 
      }
    }
    else
    {
      // if the _DEBUG_JAVASCRIPT parameter has NOT been specified, let us
      // apply the DEFAULT values for the certain Project Stages:
      // -PRODUCTION we want this value to be FALSE;
      // -other stages we use TRUE
      _debugJavascript = !(context.isProjectStage(ProjectStage.Production));
      if (_debugJavascript)
      {
        _LOG.info("RUNNING_DEBUG_JAVASCRIPT"); 
      }
    }
  }

  return _debugJavascript.booleanValue();
}
 
Example 4
Project: myfaces-trinidad   File: ViewHandlerImpl.java   View Source Code Vote up 4 votes
/**
 * Reads org.apache.myfaces.trinidad.CHECK_FILE_MODIFICATION context param and determines if
 * the flag is enabled or not.
 * If the context parameter is not specified, default value used is: "false" for
 * ProjectStage.Production and "true" for all other stages.
 * For InternalViews this method always return "false"
 *
 * @param context
 * @param viewId
 * @return
 */
private boolean _isTimestampCheckEnabled(FacesContext context, String viewId)
{
  if (_checkTimestamp == null)
  {
    boolean productionStage = context.isProjectStage(ProjectStage.Production);
    boolean checkTimestamp;
    String checkTimestampContextParam =
      context.getExternalContext().getInitParameter(Configuration.CHECK_TIMESTAMP_PARAM);
    
    if (checkTimestampContextParam != null)
    {
      checkTimestamp = "true".equals(checkTimestampContextParam);
    }
    else
    {
      // if the CHECK_TIMESTAMP_PARAM parameter has NOT been specified, let us
      // apply the DEFAULT values for the certain Project Stages:
      // -PRODUCTION we want this value to be FALSE;
      // -other stages we use TRUE
      checkTimestamp = !productionStage;
    }

    _checkTimestamp = Boolean.valueOf(checkTimestamp);

    // if Apache MyFaces Trinidad is running in ProjectStage.Production,
    // then CHECK_TIMESTAMP_PARAM should be FALSE, otherwise we generate a WARNING message
    if (productionStage && checkTimestamp)
    {
      _LOG.warning("TIMESTAMP_CHECKING_ENABLED_SHOULDNOT_IN_PRODUCTION",
          Configuration.CHECK_TIMESTAMP_PARAM);
    }
  }

  // Even if _isTimestampCheckEnabled is TRUE, we do not want to perform the check for the InternalViews
  if (_checkTimestamp
        && getViewDeclarationLanguage(context, viewId) instanceof InternalViewHandlingStrategy)
  {
    return false;
  }

  return _checkTimestamp;
}
 
Example 5
Project: myfaces-trinidad   File: SkinImpl.java   View Source Code Vote up 4 votes
private boolean _isContentCompressionDisabled(FacesContext context, RenderingContext arc)
{
  // TODO: this section needs to be MOVED up, perhaps to API,
  // as the StyleContextIMPL.java has exactly the same code;
  // this will be fixed with the advent of "TRINIDAD-1662".
  ExternalContext ec = context.getExternalContext();

  // first check to see if the DISABLE_CONTENT_COMPRESSION flag is
  // set on the request.
  String disableContentCompression = (String)ec.getRequestMap().get(Configuration.DISABLE_CONTENT_COMPRESSION);
  
  if(null == disableContentCompression || !("true".equals(disableContentCompression) || "false".equals(disableContentCompression)))
  {
    //Either nothing is set on the request or we have an invalid value that is NOT true or false.  This means we go with the ini setting.
    disableContentCompression = ec.getInitParameter(Configuration.DISABLE_CONTENT_COMPRESSION);
  }

  boolean disableContentCompressionBoolean; 

  // what value has been specified for the DISABLE_CONTENT_COMPRESSION param?
  if (disableContentCompression != null)
  {
    disableContentCompressionBoolean = "true".equals(disableContentCompression);
  }
  else 
  {
    // if the DISABLE_CONTENT_COMPRESSION parameter has NOT been specified, let us
    // apply the DEFAULT values for the certain Project Stages:
    // -PRODUCTION we want this value to be FALSE;
    // -other stages we use TRUE
    disableContentCompressionBoolean = !(context.isProjectStage(ProjectStage.Production));
  }

  // if Apache MyFaces Trinidad is running in production stage and not design time and
  // running with content compression disabled we generate a WARNING
  // message
  if (disableContentCompressionBoolean && context.isProjectStage(ProjectStage.Production)
        && !arc.isDesignTime())
  {
    _LOG.warning("DISABLE_CONTENT_COMPRESSION_IN_PRODUCTION_STAGE");
  }
  return disableContentCompressionBoolean;
}