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.richfaces.component.UICalendar.java

/**
 * Gets what the minimal days required in the first week of the year 
 are; e.g., if the first week is defined as one that contains the first 
 day of the first month of a year, this method returns 1. If the 
 minimal days required must be a full week, this method returns 7.
 * Getter for minDaysInFirstWeek/*from  ww  w.  j  av a2s.  c o m*/
 * @return minDaysInFirstWeek value from local variable or value bindings
 */
public int getMinDaysInFirstWeek() {
    if (this._minDaysInFirstWeekSet) {
        return this._minDaysInFirstWeek;
    }
    ValueExpression ve = getValueExpression("minDaysInFirstWeek");
    if (ve != null) {
        Integer value = (Integer) ve.getValue(getFacesContext().getELContext());
        if (null == value) {
            return getDefaultMinDaysInFirstWeek();
        }
        return (value.intValue());
    } else {
        return getDefaultMinDaysInFirstWeek();
    }
}

From source file:org.richfaces.component.UICalendar.java

/**
 * Gets what the first day of the week is; e.g., SUNDAY in the U.S., MONDAY in France.
 * Getter for firstWeekDay//from w  w w  . j a v a2 s .c  o m
 * @return firstWeekDay value from local variable or value bindings
 */
public int getFirstWeekDay() {
    int result;
    if (this._firstWeekDaySet) {
        result = this._firstWeekDay;
    } else {
        ValueExpression ve = getValueExpression("firstWeekDay");
        if (ve != null) {

            Integer value = (Integer) ve.getValue(getFacesContext().getELContext());
            result = (value.intValue());
        } else {
            result = getDefaultFirstWeekDay();
        }
    }
    if (result < 0 || result > 6) {
        getFacesContext().getExternalContext()
                .log(result + " value of firstWeekDay attribute is not a legal one for component: "
                        + MessageUtil.getLabel(getFacesContext(), this) + ". Default value was applied.");
        result = getDefaultFirstWeekDay();
    }
    return result;
}

From source file:org.nuxeo.ecm.platform.ui.web.directory.ChainSelect.java

/**
 * @since 5.6//from   w ww  .j  a  v a 2 s  . c  om
 */
public Boolean getResetCacheOnUpdate() {
    if (resetCacheOnUpdate != null) {
        return resetCacheOnUpdate;
    }
    ValueExpression ve = getValueExpression("resetCacheOnUpdate");
    if (ve != null) {
        try {
            return Boolean.valueOf(Boolean.TRUE.equals(ve.getValue(getFacesContext().getELContext())));
        } catch (ELException e) {
            throw new FacesException(e);
        }
    } else {
        // default value
        return Boolean.FALSE;
    }
}

From source file:inti.ws.spring.resource.template.TemplateResource.java

protected String applyTemplate(ExpressionFactory factory, String templateName, String templateFile) {
    ValueExpression var;
    Object val;
    SimpleContext templateContext = new SimpleContext();
    ValueExpression templateContent;

    templateContent = factory.createValueExpression(templateContext, template, String.class);
    var = factory.createValueExpression(templateContext, "${content}", String.class);
    var.setValue(templateContext, templateFile.replaceAll("\"", "\\\\\""));

    for (Map.Entry<String, Object> parameter : parameters.entrySet()) {
        var = factory.createValueExpression(templateContext, "${" + parameter.getKey() + '}', String.class);
        val = parameter.getValue();

        if ("$filename".equals(val)) {
            val = templateName;
        } else if ("$modulename".equals(val)) {
            val = moduleName;
        }//from  ww  w  . ja v a 2 s  . c  om

        var.setValue(templateContext, val);
    }

    return (String) templateContent.getValue(templateContext);
}

From source file:org.apache.myfaces.custom.datascroller.AbstractHtmlDataScroller.java

/**
 * MethodBinding pointing at method acception an ActionEvent with return type void.
 *
 * @see javax.faces.component.ActionSource#getActionListener()
 *///from   w w  w . ja  v a2  s.  co m
@JSFProperty(returnSignature = "void", methodSignature = "javax.faces.event.ActionEvent")
public MethodBinding getActionListener() {
    if (_actionListener != null) {
        return _actionListener;
    }
    ValueExpression expression = getValueExpression("actionListener");
    if (expression != null) {
        return (MethodBinding) expression.getValue(getFacesContext().getELContext());
    }
    return null;
}

From source file:org.apache.myfaces.config.ManagedBeanBuilder.java

private void initializeMap(FacesContext facesContext, MapEntries mapEntries,
        Map<? super Object, ? super Object> map) {
    Application application = facesContext.getApplication();

    Class<?> keyClass = (mapEntries.getKeyClass() == null) ? String.class
            : ClassUtils.simpleJavaTypeToClass(mapEntries.getKeyClass());

    Class<?> valueClass = (mapEntries.getValueClass() == null) ? String.class
            : ClassUtils.simpleJavaTypeToClass(mapEntries.getValueClass());

    ValueExpression valueExpression;
    ExpressionFactory expFactory = application.getExpressionFactory();
    ELContext elContext = facesContext.getELContext();

    for (Iterator<? extends MapEntry> iterator = mapEntries.getMapEntries(); iterator.hasNext();) {
        MapEntry entry = iterator.next();
        Object key = entry.getKey();

        if (ContainerUtils.isValueReference((String) key)) {
            valueExpression = expFactory.createValueExpression(elContext, (String) key, Object.class);
            key = valueExpression.getValue(elContext);
        }//from w  w  w .j a va 2  s.com

        if (entry.isNullValue()) {
            map.put(coerceToType(facesContext, key, keyClass), null);
        } else {
            Object value = entry.getValue();
            if (ContainerUtils.isValueReference((String) value)) {
                valueExpression = expFactory.createValueExpression(elContext, (String) value, Object.class);
                value = valueExpression.getValue(elContext);
            }

            map.put(coerceToType(facesContext, key, keyClass), coerceToType(facesContext, value, valueClass));
        }
    }
}

From source file:org.richfaces.taglib.ColumnsTag.java

/**
 * Return expression for page variables/*from   w ww .  j a  v  a 2  s . c  om*/
 * 
 * @param expr
 * @return
 */
private ValueExpression getVarExpression(ValueExpression expr) {
    Object o = expr.getValue(pageContext.getELContext());
    if (o.getClass().isArray() || o instanceof List) {
        return new IndexedValueExpression(__value, index);
    }

    if (o instanceof Collection || o instanceof Iterator || o instanceof Enumeration || o instanceof Map
            || o instanceof String) {

        if (iteratedExpression == null) {
            iteratedExpression = new IteratedExpression(__value, getDelims());
        }
        return new IteratedValueExpression(iteratedExpression, index);
    }

    throw new ELException("FOREACH_BAD_ITEMS: [" + o.getClass().getName()
            + "] is not iterable item. Only [List, Array, Collection, Enumeration, Map, String] are supported.");
}

From source file:org.openfaces.component.table.TableDataModel.java

private int requestNonPagedRowCount() {
    AbstractTable table = getTable();/*from w  w w  .  j  a  va2 s  . c  om*/
    setFilteringCriteriaToRequestVariable();
    ValueExpression valueExpression = table.getValueExpression("totalRowCount");
    if (valueExpression == null)
        throw new IllegalStateException(
                "totalRowCount must be defined for pagination with custom data providing to work. table id = "
                        + table.getClientId(FacesContext.getCurrentInstance()));
    Object value = valueExpression.getValue(FacesContext.getCurrentInstance().getELContext());
    restoreRequestVariable(VAR_FILTER_CRITERIA);
    if (value.getClass().equals(Long.class) || value.getClass().equals(long.class))
        value = ((Long) value).intValue();
    if (!(value instanceof Integer))
        throw new IllegalStateException("totalRowCount must return an int (or Integer) number, but returned: "
                + (value != null ? value.getClass().getName() : "null") + "; table id = "
                + table.getClientId(FacesContext.getCurrentInstance()));
    return (Integer) value;
}

From source file:org.apache.empire.jsf2.utils.TagEncodingHelper.java

public Object getTagAttributeValue(String name) {
    Object value = tag.getAttributes().get(name);
    if (value == null) { // try value expression
        ValueExpression ve = tag.getValueExpression(name);
        if (ve != null) { // It's a value expression
            FacesContext ctx = FacesContext.getCurrentInstance();
            value = ve.getValue(ctx.getELContext());
        }//w w w.  j a  va 2 s.co m
    }
    return value;
}

From source file:org.jbuilt.components.html.raw.base.AbstractCommandComponent.java

/**
 * @return the value/*  ww  w  . j a v a  2 s.  c  o m*/
 */
@Override
public Object getValue() {
    if (value != null) {
        return value;
    }
    ValueExpression vb = getValueExpression("value");
    if (vb != null) {
        return vb.getValue(getFacesContext().getELContext());
    }
    return null;
}