Author: hermanns Date: Wed Sep 13 04:26:36 2006 New Revision: 442944 URL: http://svn.apache.org/viewvc?view=rev&rev=442944 Log: ListTags do not allow evaluation of listValue from ValueStack o backport from WW 2.2.3/2.2.4
Issue Number: WW-1441 Added: struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/Select-7.txt (with props) Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/ListUIBean.java struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/ui/SelectTest.java Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/ListUIBean.java URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/ListUIBean.java?view=diff&rev=442944&r1=442943&r2=442944 ============================================================================== --- struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/ListUIBean.java (original) +++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/ListUIBean.java Wed Sep 13 04:26:36 2006 @@ -104,6 +104,13 @@ } 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"); Modified: struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/ui/SelectTest.java URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/ui/SelectTest.java?view=diff&rev=442944&r1=442943&r2=442944 ============================================================================== --- struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/ui/SelectTest.java (original) +++ struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/ui/SelectTest.java Wed Sep 13 04:26:36 2006 @@ -189,6 +189,36 @@ 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); Added: struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/Select-7.txt URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/Select-7.txt?view=auto&rev=442944 ============================================================================== --- struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/Select-7.txt (added) +++ struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/Select-7.txt Wed Sep 13 04:26:36 2006 @@ -0,0 +1,9 @@ +<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> \ No newline at end of file Propchange: struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/Select-7.txt ------------------------------------------------------------------------------ svn:eol-style = native