fix list when not found in stack and so is null

Also add tests for when user has supplied a not iterable list
See also WW-4910
This commit is contained in:
Yasser Zamani
2018-03-16 15:37:30 +03:30
parent 770e4ed81c
commit c3d8b47828
3 changed files with 5 additions and 1 deletions
@@ -87,7 +87,7 @@ public abstract class ListUIBean extends UIBean {
value = list;
}
if (value instanceof Iterable) {
if (value == null || value instanceof Iterable) {
addParameter("list", value);
} else if (MakeIterator.isIterable(value)) {
addParameter("list", MakeIterator.convert(value));
@@ -236,9 +236,11 @@ public class FreemarkerResultMockedTest extends StrutsInternalTestCase {
dispatcher.serviceAction(request, response, mapping);
String result = stringWriter.toString();
assertTrue(result.contains("<option value=\"a\">a</option>"));
assertTrue(result.contains("<option value=\"1\">1</option>"));
assertTrue(result.contains("<option value=\"key\">value</option>"));
assertTrue(result.contains("<option value=\"optgroupKey1\">optgroupValue1</option>"));
assertTrue(result.contains("<option value=\"optgroupKey3\">optgroupKey3</option>"));
assertTrue(result.contains("<option value=\"2\">2</option>"));
}
private void init() throws MalformedURLException, URISyntaxException {
@@ -19,8 +19,10 @@
*/
-->
<@s.select theme="simple" list=['a','b','c'] />
<@s.select theme="simple" list=1 />
<@s.select theme="simple" list={'key':'value'} />
<@s.select theme="simple">
<@s.optgroup label="label1" list={'optgroupKey1':'optgroupValue1','optgroupKey2':'optgroupValue2'} />
<@s.optgroup label="label2" disabled=true list=['optgroupKey3','optgroupKey4'] />
<@s.optgroup label="label3" disabled=true list=2 />
</@s.select>