Example usage for javax.el VariableMapper setVariable

List of usage examples for javax.el VariableMapper setVariable

Introduction

In this page you can find the example usage for javax.el VariableMapper setVariable.

Prototype

public abstract ValueExpression setVariable(String variable, ValueExpression expression);

Source Link

Usage

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

/**
 * Sets page request variables//  ww w .j  a  v a  2s .  c  o m
 * 
 * @throws JspTagException
 */
private void exposeVariables() throws JspTagException {

    /*
     * We need to support null items returned from next(); we do this simply
     * by passing such non-items through to the scoped variable as
     * effectively 'null' (that is, by calling removeAttribute()).
     * 
     * Also, just to be defensive, we handle the case of a null 'status'
     * object as well.
     * 
     * We call getCurrent() and getLoopStatus() (instead of just using
     * 'item' and 'status') to bridge to subclasses correctly. A subclass
     * can override getCurrent() or getLoopStatus() but still depend on our
     * doStartTag() and doAfterBody(), which call this method
     * (exposeVariables()), to expose 'item' and 'status' correctly.
     */

    // Set up var variable
    if (itemId != null) {
        if (index == null)
            pageContext.removeAttribute(itemId, PageContext.PAGE_SCOPE);
        else if (__value != null) {
            VariableMapper vm = pageContext.getELContext().getVariableMapper();
            if (vm != null) {
                ValueExpression ve = getVarExpression(__value);
                vm.setVariable(itemId, ve);
            }
        } else
            pageContext.setAttribute(itemId, index);
    }

    // Set up index variable

    if (indexId != null) {
        if (index == null)
            pageContext.removeAttribute(indexId, PageContext.PAGE_SCOPE);
        else {
            IteratedIndexExpression indexExpression = new IteratedIndexExpression(index);
            VariableMapper vm = pageContext.getELContext().getVariableMapper();
            if (vm != null) {
                vm.setVariable(indexId, indexExpression);
            }
        }
    }

}