Examples of coerceToType()


Examples of javax.el.ExpressionFactory.coerceToType()


        ExpressionFactory expressionFactory = createMock(ExpressionFactory.class);
        JspApplicationContext applicationContext = createMock(JspApplicationContext.class);
        JspFactory jspFactory = createMock(JspFactory.class);
        expect(expressionFactory.coerceToType(VALUE, String.class)).andStubReturn(VALUE);
        expect(expressionFactory.coerceToType(null, String.class)).andStubReturn(null);
        expect(applicationContext.getExpressionFactory()).andStubReturn(expressionFactory);
        expect(jspFactory.getJspApplicationContext(null)).andStubReturn(applicationContext);
        replay(jspFactory, applicationContext, expressionFactory);
        JspFactory.setDefaultFactory(jspFactory);
View Full Code Here

Examples of javax.el.ExpressionFactory.coerceToType()

        ExpressionFactory expressionFactory = createMock(ExpressionFactory.class);
        JspApplicationContext applicationContext = createMock(JspApplicationContext.class);
        JspFactory jspFactory = createMock(JspFactory.class);
        expect(expressionFactory.coerceToType(VALUE, String.class)).andStubReturn(VALUE);
        expect(expressionFactory.coerceToType(null, String.class)).andStubReturn(null);
        expect(applicationContext.getExpressionFactory()).andStubReturn(expressionFactory);
        expect(jspFactory.getJspApplicationContext(null)).andStubReturn(applicationContext);
        replay(jspFactory, applicationContext, expressionFactory);
        JspFactory.setDefaultFactory(jspFactory);
    }
View Full Code Here

Examples of javax.el.ExpressionFactory.coerceToType()

   public Object coerceToType(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);
      return ef.coerceToType(value, ve.getType(context.getELContext()));
   }

   public Class<?> getExpectedType(final FacesContext context, final String expression) throws ELException
   {
      ExpressionFactory ef = context.getApplication().getExpressionFactory();
View Full Code Here

Examples of javax.el.ExpressionFactory.coerceToType()

   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())));
   }

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

Examples of javax.el.ExpressionFactory.coerceToType()

        if (value == null) return null;

        try
        {
            ExpressionFactory expFactory = FacesContext.getCurrentInstance().getApplication().getExpressionFactory();
            return expFactory.coerceToType(value, desiredClass);
        }
        catch (Exception e)
        {
            String message = "Cannot coerce " + value.getClass().getName()
                             + " to " + desiredClass.getName();
View Full Code Here

Examples of javax.el.ExpressionFactory.coerceToType()

        if (value == null) return null;

        try
        {
            ExpressionFactory expFactory = FacesContext.getCurrentInstance().getApplication().getExpressionFactory();
            return expFactory.coerceToType(value, desiredClass);
        }
        catch (Exception e)
        {
            String message = "Cannot coerce " + value.getClass().getName()
                             + " to " + desiredClass.getName();
View Full Code Here

Examples of javax.el.ExpressionFactory.coerceToType()

                //   Coerce the value of the "value" expression to
                // the "target" expression value type following the Expression
                // Language coercion rules.
                ExpressionFactory expressionFactory = facesContext.getApplication().getExpressionFactory();
                value = expressionFactory.coerceToType(value, targetType);
            }

            // Call setValue()on the "target" ValueExpression with the resulting value.
            _target.setValue(elContext, value);
        }
View Full Code Here

Examples of javax.el.ExpressionFactory.coerceToType()

            ELContext el = faces.getELContext();
            Object valueObj = this.value.getValue(el);
             if (valueObj != null) {
                ExpressionFactory factory =
                      faces.getApplication().getExpressionFactory();
                valueObj = factory.coerceToType(valueObj, target.getType(el));
            }
            this.target.setValue(el, valueObj);
        }

    }
View Full Code Here

Examples of javax.el.ExpressionFactory.coerceToType()

        JspFactory jspFactory = JspFactory.getDefaultFactory();
        JspApplicationContext jspAppContext =
            jspFactory.getJspApplicationContext(pageContext.getServletContext());
        ExpressionFactory exprFactory = jspAppContext.getExpressionFactory();
        return exprFactory.coerceToType(value, expectedType);
    }

    //*********************************************************************
    // Accessor methods

View Full Code Here

Examples of javax.el.ExpressionFactory.coerceToType()

                                            Class toType) {

        Object newValue;
        try {
            ExpressionFactory ef = ctx.getApplication().getExpressionFactory();
            newValue = ef.coerceToType(value, toType);
        } catch (ELException ele) {
            newValue = value;
        } catch (IllegalArgumentException iae) {
            // If coerceToType fails, per the docs it should throw
            // an ELException, however, GF 9.0 and 9.0u1 will throw
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.