Example usage for javax.el ValueExpression setValue

List of usage examples for javax.el ValueExpression setValue

Introduction

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

Prototype

public abstract void setValue(ELContext context, Object value);

Source Link

Usage

From source file:org.springframework.faces.webflow.JsfViewFactory.java

/**
 * Walk the component tree to perform any required per-component operations.
 * /*from  w  w  w. ja v  a  2s.c  om*/
 * @param context
 * @param component
 */
private void processTree(FacesContext context, UIComponent component) {
    // Only resetting the valid flag in the RESTORE_VIEW phase,
    // not during RENDER_RESPONSE
    if (!context.getRenderResponse() && component instanceof EditableValueHolder) {
        ((EditableValueHolder) component).setValid(true);
    }
    ValueExpression binding = component.getValueExpression("binding");
    if (binding != null) {
        binding.setValue(context.getELContext(), component);
    }
    Iterator<UIComponent> it = component.getFacetsAndChildren();
    while (it.hasNext()) {
        processTree(context, it.next());
    }
}

From source file:com.googlecode.jsfFlex.component.ext.AbstractFlexUIComboBox.java

@Override
public void processUpdates(FacesContext context) {
    super.processUpdates(context);

    if (!isRendered() || !isValid()) {
        return;//from ww  w  .j  a  va2s.c  o m
    }

    ValueExpression ve = getValueExpression(TEXT_ATTR);

    if (ve != null && !ve.isReadOnly(context.getELContext())) {
        ve.setValue(context.getELContext(), getText());
        setText(null);
    }

}

From source file:org.primefaces.extensions.component.layout.Layout.java

@Override
public void processUpdates(final FacesContext fc) {
    if (!isSelfRequest(fc)) {
        super.processUpdates(fc);
    }/*from   w  ww  . j  a va  2 s .com*/

    final String state = fc.getExternalContext().getRequestParameterMap().get(this.getClientId(fc) + "_state");
    if (StringUtils.isNotBlank(state)) {
        final ValueExpression stateVE = getValueExpression(PropertyKeys.state.toString());
        if (stateVE != null) {
            // save "state"
            stateVE.setValue(fc.getELContext(), state);
            getStateHelper().remove(PropertyKeys.state);
        }
    }
}

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;/*from  w w  w .  j  a  v  a  2 s.  c  om*/

    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;
        }

        var.setValue(templateContext, val);
    }

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

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

/**
 * Puts own state into component state. 
 *///from   w ww.  ja  va2s . c  o  m
protected void updateTableState(FacesContext context) {
    ValueExpression ve = getValueExpression("tableState");
    if ((null != ve) && (!ve.isReadOnly(context.getELContext()))) {
        ve.setValue(context.getELContext(), getState().toString());
    }
}

From source file:org.primefaces.extensions.component.masterdetail.MasterDetail.java

public void updateModel(FacesContext fc, MasterDetailLevel mdlToGo) {
    final int levelToGo = mdlToGo.getLevel();
    ValueExpression levelVE = this.getValueExpression(PropertyKeys.level.toString());
    if (levelVE != null) {
        // update "level"
        levelVE.setValue(fc.getELContext(), levelToGo);
        getStateHelper().remove(PropertyKeys.level);
    }/*www . j  a  v a  2s .  c om*/

    // get component caused this ajax request
    final String source = fc.getExternalContext().getRequestParameterMap()
            .get(Constants.RequestParams.PARTIAL_SOURCE_PARAM);
    MasterDetailLevel mdl = getDetailLevelToProcess(fc);

    // get resolved context value
    Object contextValue = null;
    Map<String, Object> contextValues = (Map<String, Object>) mdl.getAttributes().get(CONTEXT_VALUES);
    if (contextValues != null) {
        contextValue = contextValues.get(RESOLVED_CONTEXT_VALUE + source);
    }

    if (contextValue != null) {
        // update current context value for corresponding MasterDetailLevel
        mdlToGo.getAttributes().put(getClientId(fc) + CURRENT_CONTEXT_VALUE, contextValue);

        ValueExpression contextValueVE = this.getValueExpression(PropertyKeys.contextValue.toString());
        if (contextValueVE != null) {
            // update "contextValue"
            contextValueVE.setValue(fc.getELContext(), contextValue);
            getStateHelper().remove(PropertyKeys.contextValue);
        }
    }
}

From source file:com.jsmartframework.web.manager.ExpressionHandler.java

void setAttributeValue(String expr, Object value) {
    if (expr != null) {
        Matcher matcher = EL_PATTERN.matcher(expr);
        if (matcher.find()) {

            String beanMethod = matcher.group(1);
            String[] methodSign = beanMethod.split(Constants.EL_SEPARATOR);

            if (methodSign.length > 0 && WebContext.containsAttribute(methodSign[0])) {
                beanMethod = String.format(Constants.JSP_EL, beanMethod);

                ELContext context = WebContext.getPageContext().getELContext();
                ValueExpression valueExpr = WebContext.getExpressionFactory().createValueExpression(context,
                        beanMethod, Object.class);
                valueExpr.setValue(context, value);
            }//from   ww w .  j  av  a  2 s .c o m
        }
    }
}

From source file:com.jsmartframework.web.manager.ExpressionHandler.java

private void setExpressionValues(String expr, String jParam) {
    if (isReadOnlyParameter(jParam)) {
        return;/*from   w w  w .j a  v a 2  s .c  o  m*/
    }

    Matcher matcher = EL_PATTERN.matcher(expr);
    if (matcher.find()) {

        String beanMethod = matcher.group(1);
        String[] methodSign = beanMethod.split(Constants.EL_SEPARATOR);

        if (methodSign.length > 0 && WebContext.containsAttribute(methodSign[0])) {
            beanMethod = String.format(Constants.JSP_EL, beanMethod);

            List<Object> list = new ArrayList<Object>();
            String[] values = WebContext.getRequest().getParameterValues(TagHandler.J_ARRAY + jParam);

            boolean unescape = HANDLER.containsUnescapeMethod(methodSign);

            if (values != null) {
                for (String val : values) {
                    try {
                        list.add(NumberUtils.createNumber(val));
                    } catch (NumberFormatException e) {
                        list.add(unescape ? val : escapeValue(val));
                    }
                }
            }

            // Check for empty value sent on array [false]
            if (list.size() == 1 && list.get(0) != null && list.get(0).equals("false")) {
                list.clear();
            }

            ELContext context = WebContext.getPageContext().getELContext();
            ValueExpression valueExpr = WebContext.getExpressionFactory().createValueExpression(context,
                    beanMethod, Object.class);
            valueExpr.setValue(context, list);
        }
    }
}

From source file:org.nuxeo.ecm.platform.ui.web.component.file.UIInputFile.java

public void updateFilename(FacesContext context, String newFilename) {
    // set filename by hand after validation
    ValueExpression ve = getValueExpression("filename");
    if (ve != null) {
        ve.setValue(context.getELContext(), newFilename);
    }//  w ww .  java2s .  c  o m
}

From source file:org.apache.myfaces.custom.aliasbean.Alias.java

/**
 * Activate this alias (ie create the temporary name).
 *//*from w ww.  j ava2 s. com*/
void make(FacesContext facesContext) {
    if (_active)
        return;

    ValueExpression aliasVB;
    if (_aliasBeanExpression == null) {
        aliasVB = _aliasComponent.getValueExpression("alias");
        if (aliasVB == null)
            return;
        _aliasBeanExpression = aliasVB.getExpressionString();
        if (_aliasBeanExpression == null)
            return;
    } else {
        aliasVB = facesContext.getApplication().getExpressionFactory()
                .createValueExpression(facesContext.getELContext(), _aliasBeanExpression, Object.class);
    }

    computeEvaluatedExpression(facesContext);

    aliasVB.setValue(facesContext.getELContext(), evaluatedExpression);
    _active = true;

    log.debug("makeAlias: " + _valueExpression + " = " + _aliasBeanExpression);
}