Commits

rainerh  committed f76fb2d

ListTags do not allow evaluation of listValue from ValueStack
Issue number: WW-1345
Obtained from:
Submitted by:
Reviewed by:

git-svn-id: http://svn.opensymphony.com/svn/webwork/trunk@2699573baa09-0c28-0410-bef9-dab3c582ae83

  • Participants
  • Parent commits ac37249

Comments (0)

Files changed (3)

File src/java/com/opensymphony/webwork/components/ListUIBean.java

         }
 
         if (listValue != null) {
+
+            if (altSyntax()) {
+                // the same logic as with findValue(String)
+                // if value start with %{ and end with }, just cut it off!
+                if (listValue.startsWith("%{") && listValue.endsWith("}")) {
+                    listValue = listValue.substring(2, listValue.length() - 1);
+                }
+            }
+
             addParameter("listValue", listValue);
         } else if (value instanceof Map) {
             addParameter("listValue", "value");

File src/test/com/opensymphony/webwork/views/jsp/ui/Select-7.txt

+<tr>
+    <td class="tdLabel"><label for="foo" class="label">mylabel:</label></td>
+    <td><select name="foo" id="foo">
+    <option value="headerKey">hello: headerValue</option>
+    <option value=""></option>
+    <option value="hello" selected="selected">hello - world</option>
+    <option value="foo">foo - bar</option>
+</select></td>
+</tr>

File src/test/com/opensymphony/webwork/views/jsp/ui/SelectTest.java

         verify(SelectTag.class.getResource("Select-1.txt"));
     }
 
+    public void testExtended() throws Exception {
+        TestAction testAction = (TestAction) action;
+        testAction.setFoo("hello");
+        testAction.setList(new String[][]{
+                {"hello", "world"},
+                {"foo", "bar"}
+        });
+
+        SelectTag tag = new SelectTag();
+        tag.setPageContext(pageContext);
+        tag.setEmptyOption("true");
+        tag.setLabel("mylabel");
+        tag.setName("foo");
+        tag.setList("list");
+        tag.setListKey("top[0]");
+        tag.setListValue("%{top[0] + ' - ' + top[1]}");
+
+        // header stuff
+        tag.setHeaderKey("headerKey");
+        tag.setHeaderValue("%{foo + ': headerValue'}");
+
+        // empty option
+        tag.setEmptyOption("true");
+
+        tag.doStartTag();
+        tag.doEndTag();
+
+        verify(SelectTag.class.getResource("Select-7.txt"));
+    }
+
     public void testGenericSimple() throws Exception {
         SelectTag tag = new SelectTag();
         prepareTagGeneric(tag);