Example usage for javax.el ValueExpression getExpectedType

List of usage examples for javax.el ValueExpression getExpectedType

Introduction

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

Prototype

public abstract Class<?> getExpectedType();

Source Link

Usage

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

private static boolean same(Object o1, Object o2) {
    if (o1 instanceof ValueExpression && o2 instanceof ValueExpression) {
        ValueExpression ve1 = (ValueExpression) o1;
        ValueExpression ve2 = (ValueExpression) o2;

        if (same(ve1.getExpressionString(), ve2.getExpressionString())
                && same(ve1.getExpectedType(), ve2.getExpectedType())) {
            return true;
        }// w  w  w  .  j  a v  a2 s  .  c o m
    }

    return (o1 != null && o1.equals(o2)) || (o1 == null && o2 == null);
}

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

@Override
protected void setProperties(UIComponent component) {
    ELContext elContext = getContext(pageContext.getELContext());
    Field[] fields = this.getClass().getDeclaredFields();
    for (Field field : fields) {
        try {/* ww w .  j a  va2  s . c o  m*/
            Object o = field.get(this);
            if (o != null && o instanceof ValueExpression) {
                String fieldName = field.getName();
                if (fieldName != null && fieldName.startsWith("_")) {
                    String attributeName = fieldName.replace("_", "");
                    if (ColumnsAttributes.FILTER_ATTRIBUTES.indexOf(attributeName) == -1
                            && ColumnsAttributes.SORT_ATTRIBUTES.indexOf(attributeName) == -1) {
                        ValueExpression ex = (ValueExpression) o;
                        ex = createValueExpression(elContext, ex);
                        component.setValueExpression(attributeName, ex);
                    } else {
                        ValueExpression ex = (ValueExpression) o;
                        ValueExpression expr = null;
                        if (!ex.isLiteralText()) {
                            expr = ELBuilder.createValueExpression(ex.getExpressionString(),
                                    ex.getExpectedType(),
                                    getFacesContext().getApplication().getExpressionFactory(),
                                    pageContext.getELContext(), itemId, indexId, getVarReplacement(),
                                    String.valueOf(index));
                        } else {
                            expr = ex;
                        }
                        component.setValueExpression(attributeName, expr);
                    }
                }

            }

        } catch (Exception e) {
            continue;
        }
    }
    // Set filterMethod attribute
    if (_filterMethod != null) {
        MethodExpression mexpr = getFacesContext().getApplication().getExpressionFactory()
                .createMethodExpression(elContext, _filterMethod.getExpressionString(), Object.class,
                        new Class[] { Object.class });
        ((HtmlColumn) component).setFilterMethod(mexpr);
    }
    // Set SortExpression attribute especially for scrollable data table
    if (_sortExpression != null) {
        ValueExpression expr = ELBuilder.createValueExpression(_sortExpression.getExpressionString(),
                _sortExpression.getExpectedType(), getFacesContext().getApplication().getExpressionFactory(),
                pageContext.getELContext(), itemId, indexId, getVarReplacement(), String.valueOf(index));
        component.setValueExpression("sortExpression", expr);
    }

}

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

/**
 * Creates value expression to be out into column
 * /*  w w w .  ja  va2  s  .  co  m*/
 * @param context
 * @param orig
 * @return
 */
private ValueExpression createValueExpression(ELContext context, ValueExpression orig) {
    ValueExpression vexpr = getFacesContext().getApplication().getExpressionFactory()
            .createValueExpression(context, orig.getExpressionString(), orig.getExpectedType());
    return vexpr;
}