コード例 #1
0
  @Override
  public Object getValue(ELContext context, Object base, Object property)
      throws NullPointerException, PropertyNotFoundException, ELException {
    context.setPropertyResolved(false);

    int start;
    Object result = null;

    if (base == null) {
      // call implicit and app resolvers
      int index = 1 /* implicit */ + appResolversSize;
      for (int i = 0; i < index; i++) {
        result = resolvers[i].getValue(context, base, property);
        if (context.isPropertyResolved()) {
          return result;
        }
      }
      // skip collection-based resolvers (map, resource, list, array, and
      // bean)
      start = index + 5;
    } else {
      // skip implicit resolver only
      start = 1;
    }

    for (int i = start; i < size; i++) {
      result = resolvers[i].getValue(context, base, property);
      if (context.isPropertyResolved()) {
        return result;
      }
    }

    return null;
  }
コード例 #2
0
  @Override
  public Object invoke(
      ELContext context, Object base, Object method, Class<?>[] paramTypes, Object[] params) {
    String targetMethod = coerceToString(method);
    if (targetMethod.length() == 0) {
      throw new ELException(new NoSuchMethodException());
    }

    context.setPropertyResolved(false);

    Object result = null;

    // skip implicit and call app resolvers
    int index = 1 /* implicit */ + appResolversSize;
    for (int i = 1; i < index; i++) {
      result = resolvers[i].invoke(context, base, targetMethod, paramTypes, params);
      if (context.isPropertyResolved()) {
        return result;
      }
    }

    // skip map, resource, list, and array resolvers
    index += 4;
    // call bean and the rest of resolvers
    for (int i = index; i < size; i++) {
      result = resolvers[i].invoke(context, base, targetMethod, paramTypes, params);
      if (context.isPropertyResolved()) {
        return result;
      }
    }

    return null;
  }
コード例 #3
0
 @SuppressWarnings("unchecked")
 public <T> T getExpressionValue(FacesContext context, String exp, Class<T> returnType) {
   ELContext elContext = context.getELContext();
   boolean propertyResolved = elContext.isPropertyResolved();
   try {
     ValueExpression valueExpression = createElExpression(elContext, exp, returnType);
     return (T) valueExpression.getValue(elContext);
   } finally {
     elContext.setPropertyResolved(propertyResolved);
   }
 }
コード例 #4
0
 protected <T> T findBean(FacesContext context, Class<T> type, String beanName) {
   ELContext elContext = context.getELContext();
   boolean propertyResolved = elContext.isPropertyResolved();
   try {
     return context
         .getApplication()
         .evaluateExpressionGet(
             context, "#" + "{" + beanName + "}", type); // Warning EL string is not closed
   } finally {
     elContext.setPropertyResolved(propertyResolved);
   }
 }
  public Class getType(ELContext env) {
    Object value = getValue(env);

    if (env.isPropertyResolved()) return value.getClass();
    else return null;
  }