Example usage for javax.el ValueExpression getValue

List of usage examples for javax.el ValueExpression getValue

Introduction

In this page you can find the example usage for javax.el ValueExpression getValue.

Prototype

public abstract Object getValue(ELContext context);

Source Link

Usage

From source file:org.n52.geolabel.component.GeoLabelComponent.java

/**
 * Check whether a specific GEO label service is known to be broken for the
 * current request/*w ww. j a va2  s . c o  m*/
 * 
 * @param context
 * @return
 */
private static boolean isServiceFailed(String endpoint, FacesContext context) {
    ValueExpression expression = context.getApplication().getExpressionFactory().createValueExpression(
            context.getELContext(), "#{geoLabelResourcesBean}", GeoLabelResourcesBean.class);
    GeoLabelResourcesBean resourcesBean = (GeoLabelResourcesBean) expression.getValue(context.getELContext());
    return resourcesBean.isGeoLabelServiceFailed(endpoint);
}

From source file:com.flexive.faces.FxJsfComponentUtils.java

public static Object getValue(UIComponent component, String attributeName) {
    ValueExpression ve = component.getValueExpression(attributeName);
    if (ve != null) {
        return ve.getValue(FacesContext.getCurrentInstance().getELContext());
    }/*from   w  ww. j ava  2  s  .  c  o  m*/
    return null;
}

From source file:ec.edu.chyc.manejopersonal.managebean.GestorTesis.java

public static GestorTesis getInstance() {
    FacesContext facesContext = FacesContext.getCurrentInstance();
    ELContext context = facesContext.getELContext();
    ValueExpression ex = facesContext.getApplication().getExpressionFactory().createValueExpression(context,
            "#{gestorTesis}", GestorTesis.class);
    return (GestorTesis) ex.getValue(context);
}

From source file:org.ajax4jsf.context.ViewResources.java

private static String evaluate(FacesContext context, Object parameterValue) {
    if (parameterValue == NULL || parameterValue == null) {
        return null;
    } else if (parameterValue instanceof ValueExpression) {
        ValueExpression expression = (ValueExpression) parameterValue;

        return (String) expression.getValue(context.getELContext());
    } else {/*from  w w w . j  a  v a  2s .c  o m*/
        return parameterValue.toString();
    }
}

From source file:ec.edu.chyc.manejopersonal.managebean.GestorPersona.java

public static GestorPersona getInstance() {
    javax.faces.context.FacesContext facesContext = javax.faces.context.FacesContext.getCurrentInstance();
    javax.el.ELContext context = facesContext.getELContext();
    javax.el.ValueExpression ex = facesContext.getApplication().getExpressionFactory()
            .createValueExpression(context, "#{gestorPersona}", GestorPersona.class);
    return (GestorPersona) ex.getValue(context);
}

From source file:org.nuxeo.ecm.platform.ui.web.util.ComponentUtils.java

public static Object getAttributeOrExpressionValue(FacesContext context, UIComponent component,
        String attributeName, Object defaultValue) {
    Object value = component.getAttributes().get(attributeName);
    if (value == null) {
        ValueExpression schemaExpr = component.getValueExpression(attributeName);
        value = schemaExpr.getValue(context.getELContext());
    }/*from   ww  w .  jav a2 s.  c  o m*/
    if (value == null) {
        value = defaultValue;
    }
    return value;
}

From source file:org.nuxeo.ecm.platform.forms.layout.facelets.FaceletHandlerHelper.java

/**
 * @since 6.0/*from  w  w w  .j  a  v a 2  s  .  co m*/
 */
public static boolean isDevModeEnabled(FaceletContext ctx) {
    // avoid stack overflow when using layout tags within the dev
    // handler
    if (Framework.isDevModeSet()) {
        NuxeoLayoutManagerBean bean = lookupBean(ctx.getFacesContext());
        if (bean.isDevModeSet()) {
            ExpressionFactory eFactory = ctx.getExpressionFactory();
            ValueExpression disableDevAttr = eFactory.createValueExpression(ctx,
                    "#{" + DEV_MODE_DISABLED_VARIABLE + "}", Boolean.class);
            if (!Boolean.TRUE.equals(disableDevAttr.getValue(ctx))) {
                return true;
            }
        }
    }
    return false;
}

From source file:org.nuxeo.ecm.platform.ui.web.util.ComponentUtils.java

/**
 * Evaluates parameters to pass to translation methods if they are value expressions.
 *
 * @since 5.7//from  w w  w.  ja va 2  s. c  o m
 */
protected static Object[] evaluateParams(FacesContext context, Object[] params) {
    if (params == null) {
        return null;
    }
    Object[] res = new Object[params.length];
    for (int i = 0; i < params.length; i++) {
        Object val = params[i];
        if (val instanceof String && ComponentTagUtils.isValueReference((String) val)) {
            ValueExpression ve = context.getApplication().getExpressionFactory()
                    .createValueExpression(context.getELContext(), (String) val, Object.class);
            res[i] = ve.getValue(context.getELContext());
        } else {
            res[i] = val;
        }
    }
    return res;
}

From source file:ec.edu.chyc.manejopersonal.managebean.GestorArticulo.java

public static GestorArticulo getInstance() {
    FacesContext facesContext = FacesContext.getCurrentInstance();
    ELContext context = facesContext.getELContext();
    ValueExpression ex = facesContext.getApplication().getExpressionFactory().createValueExpression(context,
            "#{gestorArticulo}", GestorArticulo.class);
    return (GestorArticulo) ex.getValue(context);
}

From source file:org.tinygroup.jspengine.runtime.PageContextImpl.java

/**
 * Evaluates an EL expression/*from w ww.  ja v  a  2s.c o  m*/
 *
 * @param expression The expression to be evaluated
 * @param expectedType The expected resulting type
 * @param pageContext The page context
 * @param functionMap Maps prefix and name to Method
 * @return The result of the evaluation
 */
public static Object evaluateExpression(final String expression, final Class expectedType,
        final PageContext pageContext, final ProtectedFunctionMapper functionMap) throws ELException {
    Object retValue;
    if (SecurityUtil.isPackageProtectionEnabled()) {
        try {
            retValue = AccessController.doPrivileged(new PrivilegedExceptionAction() {

                public Object run() throws Exception {
                    ELContextImpl elContext = (ELContextImpl) pageContext.getELContext();
                    elContext.setFunctionMapper(functionMap);
                    ExpressionFactory expFactory = getExpressionFactory(pageContext);
                    ValueExpression expr = expFactory.createValueExpression(elContext, expression,
                            expectedType);
                    return expr.getValue(elContext);
                }
            });
        } catch (PrivilegedActionException ex) {
            Exception realEx = ex.getException();
            if (realEx instanceof ELException) {
                throw (ELException) realEx;
            } else {
                throw new ELException(realEx);
            }
        }
    } else {
        ELContextImpl elContext = (ELContextImpl) pageContext.getELContext();
        elContext.setFunctionMapper(functionMap);
        ExpressionFactory expFactory = getExpressionFactory(pageContext);
        ValueExpression expr = expFactory.createValueExpression(elContext, expression, expectedType);
        retValue = expr.getValue(elContext);
    }
    return retValue;
}