当前位置: 首页>>代码示例>>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;未经允许,请勿转载。