Package javax.el

Examples of javax.el.ValueExpression


    setVariable(key, value, value.getClass());
  }

  public <T> void setVariable(String key, T value, Class<? extends T> type) {
    VariableMapper variableMapper = context.getVariableMapper();
    ValueExpression valueExpression = factory.createValueExpression(value, type);
    variableMapper.setVariable(key, valueExpression);
  }
View Full Code Here


    Functions functions = (Functions) context.getFunctionMapper();
    functions.setFunction(prefix, name, method);
  }

  public String resolve(String expression) {
    ValueExpression expr = factory.createValueExpression(context, expression, String.class);
    return (String) expr.getValue(context);
  }
View Full Code Here

            if (validator == null) {
                return false;
            }

            // NOTE believe it or not, getValueReference on ValueExpression is broken, so we have to do it ourselves
            ValueExpression valueExpression = ((UIComponent) input).getValueExpression("value");
            if (valueExpression != null) {
                ValueExpressionAnalyzer valueExpressionAnalyzer = new ValueExpressionAnalyzer(valueExpression);
                ValueReference vref = valueExpressionAnalyzer.getValueReference(context.getELContext());
                if (vref != null) { // valueExpressionAnalyzer can return a null value. The condition prevents a NPE
                    BeanDescriptor constraintsForClass = validator.getConstraintsForClass(vref.getBase().getClass());
View Full Code Here

                            obj.getClass());
                }

                public ValueExpression setVariable(String name,
                        ValueExpression value) {
                    ValueExpression prev = resolveVariable(name);
                    pageCtx.setAttribute(name, value.getValue(
                            FreeMarkerELContext.this));
                    return prev;
                }
            };
View Full Code Here

  )
    throws UnsupportedEncodingException
  {
    ELContext elContext = context.getELContext();

    ValueExpression valueExpression = context.getApplication()
      .getExpressionFactory()
      .createValueExpression(elContext, expression, Object.class);

    Object obj = valueExpression.getValue(elContext);

    out.print("<strong>");
    out.print(expression);
    out.print("</strong>=");
View Full Code Here

      else
        continue;

      name = Character.toLowerCase(name.charAt(0)) + name.substring(1);

      ValueExpression expr = uiComponent.getValueExpression(name);

      Class type = method.getReturnType();

      if (expr != null) {
        result.setAttribute("expr:" + name, expr.getExpressionString());
      }
      else if (method.getDeclaringClass().equals(UIComponent.class)
               || method.getDeclaringClass().equals(UIComponentBase.class)) {
      }
      else if (name.equals("family") ||
View Full Code Here

    private String evaluateExpression(String expression) {
        ELContextImpl ctx = new ELContextImpl();
        ctx.setFunctionMapper(new FMapper());
        ExpressionFactoryImpl exprFactory = new ExpressionFactoryImpl();
        ValueExpression ve = exprFactory.createValueExpression(ctx, expression,
                String.class);
        return (String) ve.getValue(ctx);
    }
View Full Code Here

                    }
                    item = new SelectItem(itemValue, label, description, disabled, escape, noSelectionOption);
                }
                else if (!(item instanceof SelectItem))
                {
                    ValueExpression expression = uiSelectItem.getValueExpression("value");
                    throw new IllegalArgumentException("ValueExpression '"
                            + (expression == null ? null : expression.getExpressionString()) + "' of UISelectItem : "
                            + RendererUtils.getPathToComponent(child) + " does not reference an Object of type SelectItem");
                }
                _nextItem = (SelectItem) item;
                return true;
            }
            else if (child instanceof UISelectItems)
            {
                _currentUISelectItems = ((UISelectItems) child);
                Object value = _currentUISelectItems.getValue();

                if (value instanceof SelectItem)
                {
                    _nextItem = (SelectItem) value;
                    return true;
                }
                else if (value != null && value.getClass().isArray())
                {
                    // value is any kind of array (primitive or non-primitive)
                    // --> we have to use class Array to get the values
                    final int length = Array.getLength(value);
                    Collection<Object> items = new ArrayList<Object>(length);
                    for (int i = 0; i < length; i++)
                    {
                        items.add(Array.get(value, i));
                    }
                    _nestedItems = items.iterator();
                    return hasNext();
                }
                else if (value instanceof Iterable)
                {
                    // value is Iterable --> Collection, DataModel,...
                    _nestedItems = ((Iterable<?>) value).iterator();
                    return hasNext();
                }
                else if (value instanceof Map)
                {
                    Map<Object, Object> map = ((Map<Object, Object>) value);
                    Collection<SelectItem> items = new ArrayList<SelectItem>(map.size());
                    for (Map.Entry<Object, Object> entry : map.entrySet())
                    {
                        items.add(new SelectItem(entry.getValue(), entry.getKey().toString()));
                    }
                   
                    _nestedItems = items.iterator();
                    return hasNext();
                }
                else
                {
                    Level level = Level.FINE;
                    if (!FacesContext.getCurrentInstance().isProjectStage(ProjectStage.Production))
                    {
                        level = Level.WARNING;
                    }

                    if (log.isLoggable(level))
                    {
                        ValueExpression expression = _currentUISelectItems.getValueExpression("value");
                        log.log(level, "ValueExpression {0} of UISelectItems with component-path {1}"
                                + " does not reference an Object of type SelectItem,"
                                + " array, Iterable or Map, but of type: {2}",
                                new Object[] {
                                    (expression == null ? null : expression.getExpressionString()),
                                    RendererUtils.getPathToComponent(child),
                                    (value == null ? null : value.getClass().getName())
                                });
                    }
                }
View Full Code Here

    {
        if (_converter != null)
        {
            return _converter;
        }
        ValueExpression expression = getValueExpression("converter");
        if (expression != null)
        {
            return (Converter) expression.getValue(getFacesContext().getELContext());
        }
        return null;
    }
View Full Code Here

    {
        Object label = component.getAttributes().get("label");
        if (label != null)
            return label.toString();

        ValueExpression expression = component.getValueExpression("label");
        if (expression != null)
            return expression.getExpressionString();
        // return (String)expression.getValue(facesContext.getELContext());

        // If no label is not specified, use clientId
        return component.getClientId(facesContext);
    }
View Full Code Here

TOP

Related Classes of javax.el.ValueExpression

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.