diff --git a/core/src/main/java/org/apache/struts2/components/ListUIBean.java b/core/src/main/java/org/apache/struts2/components/ListUIBean.java index 522197a1a..a088d56dd 100644 --- a/core/src/main/java/org/apache/struts2/components/ListUIBean.java +++ b/core/src/main/java/org/apache/struts2/components/ListUIBean.java @@ -104,6 +104,13 @@ public abstract class ListUIBean extends UIBean { } 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"); diff --git a/core/src/test/java/org/apache/struts2/views/jsp/ui/SelectTest.java b/core/src/test/java/org/apache/struts2/views/jsp/ui/SelectTest.java index a56e15b9b..d3e8fea08 100644 --- a/core/src/test/java/org/apache/struts2/views/jsp/ui/SelectTest.java +++ b/core/src/test/java/org/apache/struts2/views/jsp/ui/SelectTest.java @@ -189,6 +189,36 @@ public class SelectTest extends AbstractUITagTest { 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); diff --git a/core/src/test/resources/org/apache/struts2/views/jsp/ui/Select-7.txt b/core/src/test/resources/org/apache/struts2/views/jsp/ui/Select-7.txt new file mode 100644 index 000000000..d3688f2e5 --- /dev/null +++ b/core/src/test/resources/org/apache/struts2/views/jsp/ui/Select-7.txt @@ -0,0 +1,9 @@ + + + + \ No newline at end of file