JETT's integration with the jAgg project allows the use of the "ana" tag, which performs analytic operations on a List of items, yielding analytic results that can be populated in the resultant spreadsheet. The "ana" tag requires a body.
The analytics specified in the "analytics" attribute may be an AnalyticFunction, either built-in to the jAgg library, or custom built by the developer.
Usually, a forEach tag is used inside the body of the "ana" tag to display the analytic results.
A List of Employees is available in the beans map.
Name | Title | Salary | Overall Salary Rank | Percent Salary of Title Total |
<jt:ana items="${employees}" analytics="Rank() orderBy(salary DESC);RatioToReport(salary) partitionBy(title)" analyticsVar="analytics" valuesVar="results"><jt:forEach items="${results}" var="result">${result.object.fullName} | ${result.object.title} | ${result.object.salary} | ${result.getAnalyzedValue(0)} | ${result.getAnalyzedValue(1)}</jt:forEach></jt:ana> |
One can refer to analyzed values by passing in the indexed AnalyticFunction or by passing the index itself into the "getAnalyzedValue" method.
Whether getAnalyzedValue(0) or getAnalyzedValue(analytics[0]) is used, it gets transformed into...
Name | Title | Salary | Overall Salary Rank | Percent Salary of Title Total |
Robert Stack | Data Structures Programmer | $1000.00 | 2 | 52.63% |
Suzie Queue | Data Structures Programmer | $900.00 | 3 | 47.37% |
Elmer Fudd | Cartoon Character | $800.00 | 4 | 34.78% |
Bugs Bunny | Cartoon Character | $1500.00 | 1 | 65.22% |
Notice how Robert Stack's and Suzie Queue's percentages total 100%, as do Elmer Fudd's and Bugs Bunny's, because of the partitioning. However, the ranking has no partitioning, so the entire list is used for the ranking.