當前位置: 首頁>>代碼示例>>Java>>正文


Java FacesContext.getApplication方法代碼示例

本文整理匯總了Java中javax.faces.context.FacesContext.getApplication方法的典型用法代碼示例。如果您正苦於以下問題:Java FacesContext.getApplication方法的具體用法?Java FacesContext.getApplication怎麽用?Java FacesContext.getApplication使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.faces.context.FacesContext的用法示例。


在下文中一共展示了FacesContext.getApplication方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: _evaluateValueExpressions

import javax.faces.context.FacesContext; //導入方法依賴的package包/類
/**
 * Cut-and-paste reuse from org/apache/myfaces/context/servlet/ServletExternalContextImpl.
 *
 * Checks the Strings in the List for EL expressions and evaluates them.
 * Note that the returned List will be a copy of the given List, because
 * otherwise it will have unwanted side-effects.
 * @param context faces context
 * @param values from a query parameter that might have EL
 * @return resultant list will have any embedded EL evaluated
 */
private List<String> _evaluateValueExpressions(FacesContext context, List<String> values)
{
  // note that we have to create a new List here, because if we
  // change any value on the given List, it will be changed in the
  // NavigationCase too and the EL expression won't be evaluated again
  List<String> target = new ArrayList<String>(values.size());

  for (String value: values)
  {
    if (_isExpression(value))
    {
      if (context == null)
        throw new UnsupportedOperationException("FacesContext not established yet. Unable to resolve EL bound query" + 
                                                "parameter value: \"" + value + "\"");
      
      Application app = context.getApplication();
      String dynamicValue = app.evaluateExpressionGet(context, value, String.class);
      target.add(dynamicValue);
    }
    else
      target.add(value);
  }
  return target;
}
 
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:35,代碼來源:ServletExternalContext.java

示例2: _executeValidate

import javax.faces.context.FacesContext; //導入方法依賴的package包/類
/**
 * Executes validation logic.
 */
private void _executeValidate(FacesContext context)
{
  Application application = context.getApplication();
  application.publishEvent(context, PreValidateEvent.class, UIComponent.class, this);
  try
  {
    validate(context);
  }
  catch (RuntimeException e)
  {
    context.renderResponse();
    throw e;
  }
  finally
  {
    application.publishEvent(context, PostValidateEvent.class, UIComponent.class, this);
  }

  if (!isValid())
  {
    context.renderResponse();
  }
}
 
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:27,代碼來源:UIXEditableValueTemplate.java

示例3: createConverter

import javax.faces.context.FacesContext; //導入方法依賴的package包/類
/**
 * Create a converter for a type.
 */
static public Converter createConverter(
  FacesContext context,
  Class<?>     converterType)
{
  // Don't bother for Objects;  note that the 1.1_01 RI
  // returns null, but the spec requires a FacesException, and MyFaces
  // correctly implements that.
  
// https://issues.apache.org/jira/browse/TRINIDAD-1117
// Note - JSF 1.2 allows converter for String: https://javaserverfaces-spec-public.dev.java.net/issues/show_bug.cgi?id=131   
  if (converterType == null ||
      converterType == Object.class)
  {
    return null;
  }

  // if getType returns a type for which we support a default
  // conversion, acquire an appropriate converter instance.
  try
  {
    Application application = context.getApplication();
    return application.createConverter(converterType);
  }
  catch (FacesException e)
  {
    _LOG.warning("CANNOT_CREATE_CONVERTER_LIKELY_BECAUSE_NO_CONVERTER_REGISTERED", converterType.toString());
    return null;
  }
}
 
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:33,代碼來源:ConverterUtils.java

示例4: _getConverterWithType

import javax.faces.context.FacesContext; //導入方法依賴的package包/類
private Converter _getConverterWithType(FacesContext context)
{
  Converter converter = getConverter();
  if (converter != null)
  {
    return converter;
  }

  ValueExpression valueExpression = getValueExpression("value");
  if (valueExpression == null)
  {
    return null;
  }

  Class<?> converterType = valueExpression.getType(context.getELContext());
  // if converterType is null, String, or Object, assume
  // no conversion is needed
  if (converterType == null ||
      converterType == String.class ||
      converterType == Object.class)
  {
    return null;
  }

  // if getType returns a type for which we support a default
  // conversion, acquire an appropriate converter instance.
  try
  {
    Application application = context.getApplication();
    return application.createConverter(converterType);
  }
  catch (Exception e)
  {
    return null;
  }
}
 
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:37,代碼來源:UIXEditableValueTemplate.java

示例5: getInstance

import javax.faces.context.FacesContext; //導入方法依賴的package包/類
public Object getInstance() throws InstantiationException
{
    FacesContext facesContext = FacesContext.getCurrentInstance();
    if (facesContext == null)
    {
        log.error("Object " + getManagedBeanName() + " cannot be created since the faces context is null");
        return null;
    }

    Application application = facesContext.getApplication();
    Object resolvedObject = null;

    if (isVBExpression(getManagedBeanName()))
    {
        ValueBinding vb = application.createValueBinding(getManagedBeanName());
        if (vb != null)
        {
            resolvedObject = vb.getValue(facesContext);
        }
    }
    else
    {
        VariableResolver resolver = application.getVariableResolver();
        resolvedObject = resolver.resolveVariable(facesContext, getManagedBeanName());
    }

    return resolvedObject;
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:29,代碼來源:JsfCreator.java

示例6: _appendIcon

import javax.faces.context.FacesContext; //導入方法依賴的package包/類
private void _appendIcon(
  FacesContext     context,
  ResponseWriter   rw,
  String           iconUri,
  boolean          isRtl,
  RenderingContext rc
  ) throws IOException
{
  String styleAppender = "";
  rw.startElement("img", null);
  rw.writeAttribute("border", "0", null);
  rw.writeAttribute("align", "absmiddle", null);

  if (isPDA(rc))
  {
    if (isRtl)
    {
      rw.writeAttribute("style", "padding-left: 5px;", null);
    }
    else
    {
      rw.writeAttribute("style", "padding-right: 5px;", null);
    }
  }
  else
  {
    if (isRtl)
    {
      rw.writeAttribute("style", "padding-left: 5px; float: right;", null);
    }
    else
    {
      rw.writeAttribute("style", "padding-right: 5px; float: left;", null);
    }
  }

  Application application = context.getApplication();
  ViewHandler handler = application.getViewHandler();
  String resolvedIconUri = handler.getResourceURL(context, iconUri);
  renderEncodedResourceURI(context, "src", resolvedIconUri);
  rw.endElement("img");
}
 
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:43,代碼來源:NavigationPaneRenderer.java


注:本文中的javax.faces.context.FacesContext.getApplication方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。