Aggregate Expressions using jAgg

JETT extends JEXL to allow Aggregate Expressions inside JEXL Expressions. An aggregate expression is a custom registered function in JEXL:

jagg:eval(list, aggSpec)
            

Here, "jagg" is a namespace identifier that identifies the jAgg extension. Also, "eval" is the name of the method that executes the jAgg functionality. The "list" is the name of the List variable defined in the beans map. The "aggSpec" is an aggregator specification string, e.g. "Sum(quantity)", that defines the Aggregator used. The "list" and "aggSpec" are simply parameters to the "eval" function inside a JEXL Expression. The "aggSpec" may be a string literal, e.g. "'Sum(quantity)'", or it can be supplied with a bean variable from the beans map.

JETT uses the jAgg library to evaluate the aggregate expression. For example, if the bean name "property" evaluates to the String "salary"...

${jagg:eval(employees, 'Avg(' + property + ')')}

... the aggregator specification string is evaluated as "Avg(salary)", which yields...

1050

Any Aggregator can be specified, including those built-in to the jAgg library, or those custom built by the developer.