Example usage for javax.el ValueExpression getExpressionString

List of usage examples for javax.el ValueExpression getExpressionString

Introduction

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

Prototype

public abstract String getExpressionString();

Source Link

Usage

From source file:org.rhq.core.gui.configuration.AbstractPropertyBagUIComponentTreeFactory.java

private void addPropertySimpleValue(UIComponent parent, @Nullable UIInput input,
        ValueExpression propertyValueExpression) {
    if (!this.isGroup) {
        parent.getChildren().add(input);
        return;//from  w w w  .  j a v  a  2s .  c  om
    }

    HtmlPanelGrid panelGrid = FacesComponentUtility.addPanelGrid(parent, null, 2,
            CssStyleClasses.BUTTONS_TABLE);
    panelGrid.setColumnClasses("group-property-value-cell, group-property-members-icon-cell");
    if (input != null)
        panelGrid.getChildren().add(input);
    else
        FacesComponentUtility.addOutputText(panelGrid, null, "Member Values Differ",
                VALUES_DIFFER_TEXT_STYLE_CLASS);

    // Add the Members button which will display the "drill-down" modal panel.
    HtmlAjaxCommandLink ajaxCommandLink = FacesComponentUtility.createComponent(HtmlAjaxCommandLink.class);
    panelGrid.getChildren().add(ajaxCommandLink);
    ajaxCommandLink.setOncomplete("Richfaces.showModalPanel('"
            + this.memberValuesModalPanel.getClientId(FacesContext.getCurrentInstance()) + "');");
    //ajaxCommandLink.setReRender("rhq_propSet");
    String verb = this.config.isReadOnly() ? "View" : "Edit";
    String tooltip = verb + " Member Values";
    ajaxCommandLink.setTitle(tooltip);
    FacesComponentUtility.addParameter(ajaxCommandLink, null, "propertyExpressionString",
            propertyValueExpression.getExpressionString());
    FacesComponentUtility.addParameter(ajaxCommandLink, null, "refresh",
            ConfigRenderer.PROPERTY_SET_COMPONENT_ID);
    FacesComponentUtility.addGraphicImage(ajaxCommandLink, null, "/images/icn_member_configs.png", null);
}

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;
        }//  ww w . j ava2s .  co 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 {/*from  www .j av  a  2  s  .  co 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
 * /*from  www  .  ja v  a 2s. c o 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;
}

From source file:org.richfaces.webapp.taglib.UIComponentELTagBase.java

protected void setConverterProperty(UIComponent component, ValueExpression converter) {
    if (converter != null) {
        if (component instanceof ValueHolder) {
            ValueHolder output = (ValueHolder) component;
            if (!converter.isLiteralText()) {
                component.setValueExpression("converter", converter);
            } else {
                Converter conv = FacesContext.getCurrentInstance().getApplication()
                        .createConverter(converter.getExpressionString());
                output.setConverter(conv);
            }/*from  www .j a  v  a2  s.c o m*/
        } else {
            throw new IllegalArgumentException(
                    Messages.getMessage(Messages.NO_VALUE_HOLDER_ERROR, component.getClass().getName()));
        }
    }
}

From source file:org.richfaces.webapp.taglib.UIComponentELTagBase.java

protected void setRowKeyConverterProperty(UIComponent component, ValueExpression converter) {
    if (converter != null) {
        if (component instanceof UIDataAdaptor) {
            UIDataAdaptor data = (UIDataAdaptor) component;
            if (!converter.isLiteralText()) {
                component.setValueExpression("rowKeyConverter", converter);
            } else {
                Converter conv = FacesContext.getCurrentInstance().getApplication()
                        .createConverter(converter.getExpressionString());
                data.setRowKeyConverter(conv);
            }/*from www.  j  ava 2 s .co m*/
        } else {
            throw new IllegalArgumentException(
                    Messages.getMessage(Messages.NO_DATA_ADAPTOR, component.getClass().getName()));
        }
    }
}