View | Details | Raw Unified | Return to bug 45197
Collapse All | Expand All

(-)src/org/apache/taglibs/standard/tag/common/core/SetSupport.java (-13 / +31 lines)
Lines 27-38 Link Here
27
import java.util.Map;
27
import java.util.Map;
28
28
29
import javax.servlet.jsp.JspException;
29
import javax.servlet.jsp.JspException;
30
import javax.servlet.jsp.JspFactory;
30
import javax.servlet.jsp.JspTagException;
31
import javax.servlet.jsp.JspTagException;
31
import javax.servlet.jsp.PageContext;
32
import javax.servlet.jsp.PageContext;
32
33
33
import javax.servlet.jsp.el.ELException;
34
import javax.el.ELException;
34
import javax.servlet.jsp.el.ExpressionEvaluator;
35
import javax.el.ELContext;
35
import javax.servlet.jsp.el.VariableResolver;
36
import javax.el.ValueExpression;
37
import javax.el.VariableMapper;
38
import javax.el.ExpressionFactory;
36
39
37
import javax.servlet.jsp.tagext.BodyTagSupport;
40
import javax.servlet.jsp.tagext.BodyTagSupport;
38
41
Lines 114-122 Link Here
114
             * is made to store something in the session without any
117
             * is made to store something in the session without any
115
             * HttpSession existing).
118
             * HttpSession existing).
116
             */
119
             */
120
            ELContext myELContext = pageContext.getELContext();
121
            VariableMapper vm = myELContext.getVariableMapper();
117
            if (result != null) {
122
            if (result != null) {
118
                pageContext.setAttribute(var, result, scope);
123
                //check for instanceof valueExpression
124
                if (result instanceof ValueExpression) {
125
                    if (scope!=PageContext.PAGE_SCOPE) {
126
                        throw new JspException("Incorrect scope for ValueExpression.  PageScope is required.");
127
                    }
128
                    //set variable in var Mapper
129
                    vm.setVariable(var, (ValueExpression)result);
130
                } else {
131
                    /*
132
                    //else if not valueExpression - make sure to remove it from the Var mapper
133
                    //if the scope is page, should I remove this?
134
                    if (vm.resolveVariable(var)!=null) {
135
                        vm.setVariable(var, null);
136
                    }*/
137
                    pageContext.setAttribute(var, result, scope);
138
                }
119
            } else {
139
            } else {
140
                //make sure to remove it from the Var mapper
141
                if (vm.resolveVariable(var)!=null) {
142
                    vm.setVariable(var, null);
143
                }
120
                if (scopeSpecified)
144
                if (scopeSpecified)
121
                    pageContext.removeAttribute(var, scope);
145
                    pageContext.removeAttribute(var, scope);
122
                else
146
                else
Lines 179-193 Link Here
179
     * rules of the Expression Language.
203
     * rules of the Expression Language.
180
     */
204
     */
181
    private Object convertToExpectedType(final Object value, Class expectedType) throws ELException {
205
    private Object convertToExpectedType(final Object value, Class expectedType) throws ELException {
182
        ExpressionEvaluator evaluator = pageContext.getExpressionEvaluator();
206
        JspFactory jspFactory = JspFactory.getDefaultFactory();
183
        return evaluator.evaluate( "${result}",
207
        ExpressionFactory expressionFactory = jspFactory.getJspApplicationContext(pageContext.getServletContext()).getExpressionFactory();
184
                                   expectedType,
208
        return expressionFactory.coerceToType(value, expectedType);
185
                                   new VariableResolver() {
186
                                       public Object resolveVariable(String pName) throws ELException {
187
                                           return value;
188
                                       }
189
                                   },
190
                                   null);
191
    }
209
    }
192
210
193
    //*********************************************************************
211
    //*********************************************************************

Return to bug 45197