SPR-6923 SpEL resolving nested property as outer object
This commit is contained in:
parent
af4b22e5b9
commit
50c5593740
|
|
@ -150,7 +150,7 @@ public class EvalTag extends HtmlEscapingAwareTag {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canRead(EvaluationContext context, Object target, String name) throws AccessException {
|
public boolean canRead(EvaluationContext context, Object target, String name) throws AccessException {
|
||||||
return (resolveImplicitVariable(name) != null || this.pageContext.findAttribute(name) != null);
|
return target == null && (resolveImplicitVariable(name) != null || this.pageContext.findAttribute(name) != null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public TypedValue read(EvaluationContext context, Object target, String name) throws AccessException {
|
public TypedValue read(EvaluationContext context, Object target, String name) throws AccessException {
|
||||||
|
|
|
||||||
|
|
@ -90,6 +90,17 @@ public class EvalTagTests extends AbstractTagTests {
|
||||||
assertEquals(new BigDecimal(".25"), context.getAttribute("foo"));
|
assertEquals(new BigDecimal(".25"), context.getAttribute("foo"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SPR-6923
|
||||||
|
public void testNestedPropertyWithAttribtueName() throws Exception {
|
||||||
|
tag.setExpression("bean.bean");
|
||||||
|
tag.setVar("foo");
|
||||||
|
int action = tag.doStartTag();
|
||||||
|
assertEquals(Tag.EVAL_BODY_INCLUDE, action);
|
||||||
|
action = tag.doEndTag();
|
||||||
|
assertEquals(Tag.EVAL_PAGE, action);
|
||||||
|
assertEquals("not the bean object", context.getAttribute("foo"));
|
||||||
|
}
|
||||||
|
|
||||||
public static class Bean {
|
public static class Bean {
|
||||||
|
|
||||||
public String method() {
|
public String method() {
|
||||||
|
|
@ -104,6 +115,9 @@ public class EvalTagTests extends AbstractTagTests {
|
||||||
public String html() {
|
public String html() {
|
||||||
return "<p>";
|
return "<p>";
|
||||||
}
|
}
|
||||||
|
public String getBean() {
|
||||||
|
return "not the bean object";
|
||||||
|
}
|
||||||
|
|
||||||
public String js() {
|
public String js() {
|
||||||
return "function foo() { alert(\"hi\") }";
|
return "function foo() { alert(\"hi\") }";
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue