Skip to content

Commit

Permalink
WW-4482 Fallbacks to non-collection evaluation for non-collection param
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaszlenart committed Apr 2, 2015
1 parent 6021995 commit 4a08f07
Showing 1 changed file with 8 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -212,13 +212,14 @@ public Object evaluate(String parsedValue) {

Object result = parser.evaluate(openChars, expression, ognlEval, maxLoopCount);

XWorkConverter conv = ((Container)context.get(ActionContext.CONTAINER)).getInstance(XWorkConverter.class);

Collection<String> resultCol;
if (result instanceof Collection) {
@SuppressWarnings("unchecked")
Collection<Object> casted = (Collection<Object>)result;
resultCol = new ArrayList<String>(casted.size());
resultCol = new ArrayList<String>();

XWorkConverter conv = ((Container)context.get(ActionContext.CONTAINER)).getInstance(XWorkConverter.class);

for (Object element : casted) {
String stringElement = (String)conv.convertValue(context, element, String.class);
if (shallBeIncluded(stringElement, excludeEmptyElements)) {
Expand All @@ -229,13 +230,10 @@ public Object evaluate(String parsedValue) {
}
}
} else {
resultCol = new ArrayList<String>(1);
String stringResult = (String)conv.convertValue(context, result, String.class);
if (shallBeIncluded(stringResult, excludeEmptyElements)) {
if (evaluator != null) {
stringResult = evaluator.evaluate(stringResult).toString();
}
resultCol.add(stringResult);
resultCol = new ArrayList<String>();
String resultStr = translateVariables(expression, stack, evaluator);
if (shallBeIncluded(resultStr, excludeEmptyElements)) {
resultCol.add(resultStr);
}
}

Expand Down

0 comments on commit 4a08f07

Please sign in to comment.