ListTags do not allow evaluation of listValue from ValueStack

o backport from WW 2.2.3/2.2.4

Issue Number: WW-1441

git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/trunk@442944 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Rainer Hermanns
2006-09-13 11:26:36 +00:00
parent e9c8117e4f
commit a091eab487
3 changed files with 46 additions and 0 deletions
@@ -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");
@@ -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);
@@ -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>