Example usage for javax.el ELContext getFunctionMapper

List of usage examples for javax.el ELContext getFunctionMapper

Introduction

In this page you can find the example usage for javax.el ELContext getFunctionMapper.

Prototype

public abstract FunctionMapper getFunctionMapper();

Source Link

Usage

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

/**
 * Create custom context with VariableMapper override.
 * //from w  w w. j  ava2s .  c o m
 * @param context
 * @return
 */
private ELContext getContext(final ELContext cont) {
    return new ELContext() {

        @Override
        public Object getContext(Class key) {
            return cont.getContext(key);
        }

        @Override
        public ELResolver getELResolver() {
            return cont.getELResolver();
        }

        @Override
        public FunctionMapper getFunctionMapper() {
            return cont.getFunctionMapper();
        }

        @Override
        public VariableMapper getVariableMapper() {
            return new VariableMapper() {

                @Override
                public ValueExpression resolveVariable(String variable) {
                    if (variable.equals(itemId)) {
                        return new IndexedValueExpression(__value, index);
                    } else if (variable.equals(indexId)) {
                        return new IteratedIndexExpression(index);
                    }
                    return cont.getVariableMapper().resolveVariable(variable);
                }

                @Override
                public ValueExpression setVariable(String variable, ValueExpression expression) {
                    return cont.getVariableMapper().setVariable(variable, expression);
                }

            };
        }

    };
}