use of org.thymeleaf.standard.expression.Each in project thymeleaf by thymeleaf.
the class StandardEachTagProcessor method doProcess.
@Override
protected void doProcess(final ITemplateContext context, final IProcessableElementTag tag, final AttributeName attributeName, final String attributeValue, final IElementTagStructureHandler structureHandler) {
final Each each = EachUtils.parseEach(context, attributeValue);
final IStandardExpression iterVarExpr = each.getIterVar();
final Object iterVarValue = iterVarExpr.execute(context);
final IStandardExpression statusVarExpr = each.getStatusVar();
final Object statusVarValue;
if (statusVarExpr != null) {
statusVarValue = statusVarExpr.execute(context);
} else {
// Will provoke the default behaviour: iterVarValue + 'Stat'
statusVarValue = null;
}
final IStandardExpression iterableExpr = each.getIterable();
final Object iteratedValue = iterableExpr.execute(context);
final String iterVarName = (iterVarValue == null ? null : iterVarValue.toString());
if (StringUtils.isEmptyOrWhitespace(iterVarName)) {
throw new TemplateProcessingException("Iteration variable name expression evaluated as null: \"" + iterVarExpr + "\"");
}
final String statusVarName = (statusVarValue == null ? null : statusVarValue.toString());
if (statusVarExpr != null && StringUtils.isEmptyOrWhitespace(statusVarName)) {
throw new TemplateProcessingException("Status variable name expression evaluated as null or empty: \"" + statusVarExpr + "\"");
}
structureHandler.iterateElement(iterVarName, statusVarName, iteratedValue);
}
Aggregations