Examples of ExpressionFactory


Examples of javax.el.ExpressionFactory

  public static Object proprietaryEvaluate(final String expression,
      final Class expectedType, final PageContext pageContext,
      final ProtectedFunctionMapper functionMap, final boolean escape)
      throws ELException {
    Object retValue;
        final ExpressionFactory exprFactory = jspf.getJspApplicationContext(pageContext.getServletContext()).getExpressionFactory();
    if (SecurityUtil.isPackageProtectionEnabled()) {
      try {
        retValue = AccessController
            .doPrivileged(new PrivilegedExceptionAction() {

              public Object run() throws Exception {
                                ELContextImpl ctx = (ELContextImpl) pageContext.getELContext();
                                ctx.setFunctionMapper(new FunctionMapperImpl(functionMap));
                ValueExpression ve = exprFactory.createValueExpression(ctx, expression, expectedType);
                                return ve.getValue(ctx);
              }
            });
      } catch (PrivilegedActionException ex) {
        Exception realEx = ex.getException();
        if (realEx instanceof ELException) {
          throw (ELException) realEx;
        } else {
          throw new ELException(realEx);
        }
      }
    } else {
            ELContextImpl ctx = (ELContextImpl) pageContext.getELContext();
            ctx.setFunctionMapper(new FunctionMapperImpl(functionMap));
            ValueExpression ve = exprFactory.createValueExpression(ctx, expression, expectedType);
            retValue = ve.getValue(ctx);
    }
    if (escape && retValue != null) {
      retValue = XmlEscape(retValue.toString());
    }
View Full Code Here

Examples of javax.el.ExpressionFactory

    {
        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

    {
        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

    public static Object proprietaryEvaluate(final String expression,
            final Class expectedType, final PageContext pageContext,
            final ProtectedFunctionMapper functionMap, final boolean escape)
            throws ELException {
        Object retValue;
        final ExpressionFactory exprFactory = jspf.getJspApplicationContext(pageContext.getServletContext()).getExpressionFactory();
        if (SecurityUtil.isPackageProtectionEnabled()) {
            try {
                retValue = AccessController
                        .doPrivileged(new PrivilegedExceptionAction() {

                            public Object run() throws Exception {
                                ELContextImpl ctx = (ELContextImpl) pageContext.getELContext();
                                ctx.setFunctionMapper(new FunctionMapperImpl(functionMap));
                                ValueExpression ve = exprFactory.createValueExpression(ctx, expression, expectedType);
                                return ve.getValue(ctx);
                            }
                        });
            } catch (PrivilegedActionException ex) {
                Exception realEx = ex.getException();
                if (realEx instanceof ELException) {
                    throw (ELException) realEx;
                } else {
                    throw new ELException(realEx);
                }
            }
        } else {
            ELContextImpl ctx = (ELContextImpl) pageContext.getELContext();
            ctx.setFunctionMapper(new FunctionMapperImpl(functionMap));
            ValueExpression ve = exprFactory.createValueExpression(ctx, expression, expectedType);
            retValue = ve.getValue(ctx);
        }
        if (escape && retValue != null) {
            retValue = XmlEscape(retValue.toString());
        }
View Full Code Here

Examples of javax.el.ExpressionFactory

* @version $Revision: $
*/
public class JuelTest extends TestCase {

    public void testJuel() throws Exception {
        ExpressionFactory factory = ExpressionFactory.newInstance();
        ELContext context  = new SimpleContext();
        ValueExpression valueExpression = factory.createValueExpression(context, "${123 * 2}", Object.class);
        Object value = valueExpression.getValue(context);

        System.out.println("Found: " + value + " for expression: " + valueExpression);
    }
View Full Code Here

Examples of javax.el.ExpressionFactory

                // beacuse type we have objValue already

                //   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

    {
        assert _condition != null;

        if (_conditionExpression == null)
        {
            ExpressionFactory factory = context.getApplication().getExpressionFactory();
            _conditionExpression = factory.createValueExpression(context.getELContext(), _condition, Boolean.class);
        }

        return _conditionExpression;
    }
View Full Code Here

Examples of javax.el.ExpressionFactory

    {
        assert _toViewId != null;

        if (_toViewIdExpression == null)
        {
            ExpressionFactory factory = context.getApplication().getExpressionFactory();
            _toViewIdExpression = factory.createValueExpression(context.getELContext(), _toViewId, String.class);
        }

        return _toViewIdExpression;
    }
View Full Code Here

Examples of javax.el.ExpressionFactory

    public final <T> T evaluateExpressionGet(final FacesContext context, final String expression,
                                             final Class<? extends T> expectedType) throws ELException
    {
        ELContext elContext = context.getELContext();

        ExpressionFactory factory = getExpressionFactory();

        return (T) factory.createValueExpression(elContext, expression, expectedType).getValue(elContext);
    }
View Full Code Here

Examples of javax.el.ExpressionFactory

        MockFacesContext12 facesContext = new MockFacesContext12();
        IMocksControl mocksControl = EasyMock.createControl();
        Application application = mocksControl.createMock(Application.class);
        ViewHandler viewHandler = mocksControl.createMock(ViewHandler.class);
        ELContext elContext = mocksControl.createMock(ELContext.class);
        ExpressionFactory expressionFactory = mocksControl.createMock(ExpressionFactory.class);
        ValueExpression valueExpression = mocksControl.createMock(ValueExpression.class);
        facesContext.setApplication(application);
        facesContext.setViewRoot(root);
        facesContext.setELContext(elContext);
       
        expect(application.getViewHandler()).andReturn(viewHandler);
        expect(viewHandler.calculateLocale(facesContext)).andReturn(Locale.ENGLISH);
        expect(application.getMessageBundle()).andReturn("javax.faces.Messages");
        expect(application.getExpressionFactory()).andReturn(expressionFactory);
        String s = "xxx: Validation Error: Value is greater than allowable maximum of \"xyz\"";
        expect(expressionFactory.createValueExpression(elContext,s,String.class)).andReturn(valueExpression);
        expect(valueExpression.getValue(elContext)).andReturn(s);
        mocksControl.replay();

        assertEquals(_MessageUtils.getErrorMessage(facesContext, "javax.faces.validator.DoubleRangeValidator.MAXIMUM",
                new Object[] { "xyz", "xxx" }).getDetail(),
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.