Package javax.el

Examples of javax.el.ValueExpression


   }

   public Class<?> getExpectedType(final FacesContext context, final String expression) throws ELException
   {
      ExpressionFactory ef = context.getApplication().getExpressionFactory();
      ValueExpression ve = ef.createValueExpression(context.getELContext(), expression, Object.class);
      return ve.getType(context.getELContext());
   }
View Full Code Here


   }

   public Object getValue(final FacesContext context, final String expression) throws ELException
   {
      ExpressionFactory ef = context.getApplication().getExpressionFactory();
      ValueExpression ve = ef.createValueExpression(context.getELContext(), expression, Object.class);
      return ve.getValue(context.getELContext());
   }
View Full Code Here

   }

   public void setValue(final FacesContext context, final String expression, final Object value) throws ELException
   {
      ExpressionFactory ef = context.getApplication().getExpressionFactory();
      ValueExpression ve = ef.createValueExpression(context.getELContext(), expression, Object.class);
      ve.setValue(context.getELContext(), ef.coerceToType(value, ve.getType(context.getELContext())));
   }
View Full Code Here

   }

   public ValueExpression createValueExpression(final FacesContext context, final String expression) throws ELException
   {
      ExpressionFactory ef = context.getApplication().getExpressionFactory();
      ValueExpression ve = ef.createValueExpression(context.getELContext(), expression, Object.class);
      return ve;
   }
View Full Code Here

   public void submitValue(String expression, Object value) throws UnsupportedOperationException
   {
      FacesContext facesContext = getFacesContext();
      ELContext elContext = facesContext.getELContext();

      ValueExpression valueExpression = getValueExpression(facesContext, expression);
      Class<?> referencedType = valueExpression.getType(elContext);

      // the value that will be injected
      Object toInject = null;

      // the expression is referencing an array
      if (referencedType.isArray()) {

         // ensure the value that will be injected is an array
         if (value != null && !value.getClass().isArray()) {
            toInject = new Object[] { value };
         }
         else {
            toInject = value;
         }

      }

      // expression is not referencing an array
      else {

         // if value to inject is an array, just use the first element
         if (value != null && value.getClass().isArray()) {
            Object[] valueAsArray = (Object[]) value;
            if (valueAsArray.length > 0) {
               toInject = valueAsArray[0];
            }
            else {
               toInject = null;
            }
         }

         // simple case: neither the expression is referencing an array nor the value is one
         else {
            toInject = value;
         }

      }

      // set the value
      Object coercedValue = facesContext.getApplication().getExpressionFactory().coerceToType(toInject, referencedType);
      valueExpression.setValue(elContext, coercedValue);

   }
View Full Code Here

         {
            FacesContext context = FacesContext.getCurrentInstance();
            Application app = context.getApplication();

            ExpressionFactory expressionFactory = app.getExpressionFactory();
            ValueExpression ve = expressionFactory.createValueExpression(attribute, Object.class);
            component.setValueExpression(attributeName, ve);
         }
         else
         {
            component.getAttributes().put(attributeName, attribute);
View Full Code Here

    * Helpers
    */
   private Class<?> getExpectedType(final ELContext context, final ExpressionFactory factory, final String expression)
            throws ELException
   {
      ValueExpression ve = factory.createValueExpression(context, expression, Object.class);
      return ve.getType(context);
   }
View Full Code Here

   }

   private Object getValue(final ELContext context, final ExpressionFactory factory, final String expression)
            throws ELException
   {
      ValueExpression ve = factory.createValueExpression(context, expression, Object.class);
      return ve.getValue(context);
   }
View Full Code Here

   private void setValue(final ELContext context, final ExpressionFactory factory, final String expression,
            final Object value) throws ELException
   {

      ValueExpression ve = factory.createValueExpression(context, expression, Object.class);
      ve.setValue(context, factory.coerceToType(value, ve.getType(context)));
   }
View Full Code Here

    }

    private Converter getConverterForValue(FacesContext context, UIComponent component) {
        Converter converter = ((ValueHolder) component).getConverter();
        if (converter == null) {
            ValueExpression expression = component.getValueExpression("value");

            if (expression != null) {
                Class<?> containerClass = ServiceTracker.getService(context, GenericsIntrospectionService.class)
                    .getContainerClass(context, expression);
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.