From a6516a24cb9e5edcadd62779e4f88331d506cfc2 Mon Sep 17 00:00:00 2001 From: Yasser Zamani Date: Thu, 15 Mar 2018 21:26:15 +0330 Subject: [PATCH] fix two issues for ListUIBean fix listkey and listvalue when list is not string fix if statement location for when list is string but not found --- .../apache/struts2/components/ListUIBean.java | 30 +++++++++---------- 1 file changed, 14 insertions(+), 16 deletions(-) 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 7d835d322..ab8e6037e 100644 --- a/core/src/main/java/org/apache/struts2/components/ListUIBean.java +++ b/core/src/main/java/org/apache/struts2/components/ListUIBean.java @@ -70,25 +70,23 @@ public abstract class ListUIBean extends UIBean { if (list instanceof String) { value = findValue((String) list); - } else if (list instanceof Collection || list instanceof Map) { - value = list; - } else if (MakeIterator.isIterable(list)) { - value = MakeIterator.convert(list); - } - if (value == null) { - if (throwExceptionOnNullValueAttribute) { - // will throw an exception if not found - value = findValue((list == null) ? (String) list : list.toString(), "list", - "The requested list key '" + list + "' could not be resolved as a collection/array/map/enumeration/iterator type. " + - "Example: people or people.{name}"); - } else { - // ww-1010, allows value with null value to be compatible with ww - // 2.1.7 behaviour - value = findValue((list == null) ? (String) list : list.toString()); + if (value == null) { + if (throwExceptionOnNullValueAttribute) { + // will throw an exception if not found + value = findValue((list == null) ? (String) list : list.toString(), "list", + "The requested list key '" + list + "' could not be resolved as a collection/array/map/enumeration/iterator type. " + + "Example: people or people.{name}"); + } else { + // ww-1010, allows value with null value to be compatible with ww + // 2.1.7 behaviour + value = findValue((list == null) ? (String) list : list.toString()); + } } + } else { + value = list; } - if (value instanceof Collection) { + if (value instanceof Iterable || !MakeIterator.isIterable(value)) { addParameter("list", value); } else { addParameter("list", MakeIterator.convert(value));