#aggregates with Spring

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

#aggregates with Spring

tkoski
I'm using a map that holds some lists of objects and I'd like to #aggregate.sum(row.value.{amount}) where row.value is the ArrayList from the map and amount is the property I'm trying to sum on. This appears to follow the syntax of the tutorial which has #aggregates.sum(o.orderLines.{purchasePrice * amount}). When I try to hit the report I'm trying to generate I'm getting an error from spring which is shown below which seems to be complaining that it does not know what to do with the curly bracket. Is my syntax off somehow or is there some other issue I'm not seeing?

Spring error:
org.springframework.expression.spel.SpelParseException: EL1049E:(pos 25): Unexpected data after '.': 'lcurly({)'

Code snippet:
<div class = "container" th:each = "row : ${report.projectItemMap}">
                                                                                                                                                                                                                       
                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                    <tfooter>
                                                                                                                                                                                                                                </tfooter>

           
                            Project ID
                       
                            Type
                       
                            Date
                       
                            Source Name
                       
                            Item
                       
                            Qty
                       
                            Amount
                       
                            Missing Project ID
                       

                       

                       

                       

                       

                       

                       

        </div>
Reply | Threaded
Open this post in threaded view
|

Re: #aggregates with Spring

danielfernandez
Administrator
The problem is you are using the wrong expression language. The expression you are referencing is from the "Using Thymeleaf" guide example application (Good Thymes Virtual Grocery), which does not use Spring MVC and therefore uses OGNL as an expression language instead of Spring Expression Language (SpEL).

In SpEL, instead of "row.value.{amount}" you should write "row.value.![amount]".

For more examples, please refer to the section on "collection projection" from the Spring Expression Language reference at the Spring documentation: http://static.springsource.org/spring/docs/3.1.x/spring-framework-reference/html/expressions.html#d0e12924

Regards,
Daniel
Reply | Threaded
Open this post in threaded view
|

Re: #aggregates with Spring

tkoski
Thank you! I was trying to search for that documentation but I didn't know exactly what I was looking for so Google wasn't much help.
Reply | Threaded
Open this post in threaded view
|

Re: #aggregates with Spring

muhammad shah
In reply to this post by danielfernandez
It works