public void evaluateExtraParams() {
Object value = null;
if (list == null) {
list = parameters.get("list");
}
if (list instanceof String) {
value = findValue((String) list);
} else if (list instanceof Collection) {
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 instanceof Collection) {
addParameter("list", value);
} else {
addParameter("list", MakeIterator.convert(value));
}
if (value instanceof Collection) {
addParameter("listSize", new Integer(((Collection) value).size()));
} else if (value instanceof Map) {
addParameter("listSize", new Integer(((Map) value).size()));
} else if (value != null && value.getClass().isArray()) {
addParameter("listSize", new Integer(Array.getLength(value)));
}
if (listKey != null) {
addParameter("listKey", listKey);
} else if (value instanceof Map) {
addParameter("listKey", "key");
}
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");
}
}
|