Anonymous avatar Anonymous committed 8fc2d49

XW-88: Making Map's entries available when the map is pushed onto the ValueStack

git-svn-id: e221344d-f017-0410-9bd5-d282ab1896d7

Comments (0)

Files changed (2)


                 Object o =;
                 try {
-                    if (OgnlRuntime.hasGetProperty(ognlContext, o, name)) {
+                    if ((OgnlRuntime.hasGetProperty(ognlContext, o, name)) || ((o instanceof Map) && ((Map)o).containsKey(name))) {
                         Object value = OgnlRuntime.getProperty(ognlContext, o, name);
                         //Ognl.getValue(OgnlUtil.compile((String) name), context, o);


         assertEquals("bar", foo.getBar().getTitle());
         assertEquals(123, foo.getBar().getSomethingElse());
+    public void testMapEntriesAvailableByKey() {
+        Foo foo = new Foo();
+        String title = "a title";
+        foo.setTitle(title);
+        OgnlValueStack vs = new OgnlValueStack();
+        vs.push(foo);
+        Map map = new HashMap();
+        String a_key = "a";
+        String a_value = "A";
+        map.put(a_key,a_value);
+        String b_key = "b";
+        String b_value = "B";
+        map.put(b_key,b_value);
+        vs.push(map);
+        assertEquals(title, vs.findValue("title"));
+        assertEquals(a_value, vs.findValue(a_key));
+        assertEquals(b_value, vs.findValue(b_key));
+    }
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.